Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SphinxKnight
Copy link
Member

@SphinxKnight SphinxKnight commented Mar 25, 2022

Summary

#5813

Problem

See #5813

This would help add redirects for deleted content which now lives outside of MDN (e.g. Fx DevTools)

Solution

I added a check to switch case when the URL is absolute (vs when it's not where it uses the existing logic)


Before

image

After

image

How did you test this change?

I ran the following command from yaris directory:

yarn tool delete Tools/3D_View fr --redirect https://firefox-source-docs.mozilla.org/devtools-user/3d_view/index.html

and then manually check the redirects file and ran
yarn tool validate-redirects fr --strict (resp. w/ yarn content under content)

@schalkneethling schalkneethling requested a review from ddbeck March 25, 2022 12:41
@schalkneethling schalkneethling self-assigned this Mar 25, 2022
@schalkneethling schalkneethling added πŸ§‘β€πŸ€β€πŸ§‘ community contributions by our wonderful community πŸš‰ platform keeping the platform healthy labels Mar 25, 2022
@SphinxKnight SphinxKnight changed the title feat(CLI): Make it possible to use an absolute URL when providing a redirect feat(CLI): Make it possible to use an absolute URL when providing a redirect during a deletion Mar 25, 2022
Copy link
Contributor

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve of this change, though I think @schalkneethling would be a better judge of the code here.

Also, I'm surprised this didn't work already, since I used yarn content delete --redirect with absolute URLs a bunch of times for mdn/content#14140. πŸ€”

@SphinxKnight
Copy link
Member Author

I approve of this change, though I think @schalkneethling would be a better judge of the code here.

Also, I'm surprised this didn't work already, since I used yarn content delete --redirect with absolute URLs a bunch of times for mdn/content#14140. thinking

That's confusing. To be sure, I did fetch a whole new copy of mdn/content (and mdn/translated-content on my machine) and I get an error with the following:

  • command example with locale yarn content delete Tools/3D_View fr --redirect https://firefox-source-docs.mozilla.org/devtools-user/3d_view/index.html
  • without any locale yarn content delete Mozilla/Add-Ons/Contact_us --redirect https://firefox-source-docs.mozilla.org/devtools-user/3d_view/index.html

FWIW
yarn version: 1.22.17
Node.js version: 16.14.2

@ddbeck
Copy link
Contributor

ddbeck commented Mar 25, 2022

Hmm. What error do you get?

@SphinxKnight
Copy link
Member Author

error: Invalid URL

error Command failed with exit code 1.

image

if (dry) {
if (redirectUrl) {
Redirect.add(locale, [[url, buildURL(locale, redirectUrl)]], { dry });
Redirect.add(locale, [[url, redirectUrl]], { dry });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to what I intended to fix but it seemed to me that this was unecessary since redirectURL had already been built.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that redirects can be made to external URLs, let alone absolute URLs -- apologies for breaking this in the first place, but thanks for fixing it up!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is yet another case for us documenting how the various parts of Yari works. This is something I am planing on doing very, very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

πŸ§‘β€πŸ€β€πŸ§‘ community contributions by our wonderful community πŸš‰ platform keeping the platform healthy

Projects

Development

Successfully merging this pull request may close these issues.

4 participants