CLI `add-redirect` doesn't conform to other command conventions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 57
- Forks
- 47
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 68
Description
Summary
Most of the CLI commands use slugs as paths with an optional locale (defaulting to en-US), e.g.:
yarn content move Learn/Accessibility Learn/A11y
yarn content delete <document-slug> [locale] --redirect <redirect-slug-or-url>
The add-redirect expects absolute URLs:
yarn content add-redirect "https://developer.mozilla.org/en-US/docs/Learn" \
"https://developer.mozilla.org/en-US/docs/Web/API/URL/URL\#examples"
# ...
info: Saved '/en-US/docs/Learn' → '/en-US/docs/Web/API/URL/URL/'
yarn content add-redirect "https://developer.mozilla.org/en-US/docs/not/existing/page" \
"https://developer.mozilla.org/en-US/docs/Web/API/URL/URL\#examples"
# ...
info: Saved '/en-US/docs/not/existing/page' → '/en-US/docs/Web/API/URL/URL/'
It might be consistent to behave like this:
yarn content add-redirect <document-slug> [locale] <redirect-slug-or-url>
URL
https://github.com/mdn/content/pull/27913
Reproduction steps
Run example command:
yarn content add-redirect Learn Web/API/URL/URL
Expected behavior
A redirect is added, i.e.:
info: Saved '/en-US/docs/Learn' → '/en-US/docs/Web/API/URL/URL/'
Actual behavior
invalid URL error
Device
Desktop
Browser
Firefox
Browser version
Stable
Operating system
Mac OS
Screenshot
No response
Anything else?
Is there something we're overlooking why it's necessary to use absolute URLs like this?
Suggestion from Josh:
The fix is trivial: just add
"https://developer.mozilla.org/en-US/docs"as the base, so that/en-US/docs/Web/API/URL/URL,Web/API/URL/URL, andhttps://developer.mozilla.org/en-US/docs/Web/API/URL/URLwill all work.
Validations
- I have read the Community Participation Guidelines.
- I have verified that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- I have checked that this is a concrete bug. For Q&A open a GitHub Discussion.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the CLI entry point for the content add-redirect command and reproduce the documented slug-based invocation. The change is complete when document slugs, optional locales, paths, and absolute URLs are accepted consistently and the command reports the expected saved redirect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100