mdn / mdn/rari

CLI `add-redirect` doesn't conform to other command conventions

Open
#162 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

effort: medium enhancement idle p3
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, and https://developer.mozilla.org/en-US/docs/Web/API/URL/URL will all work.

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.