Construct repository links for nonextant targets same as for extant ones

What does this MR do and why?

Construct repository links for nonextant targets same as for extant ones

We'll always call them blobs, but that's fine --- they don't exist anyway. The point is that the links we produce are predictable, and will trigger a nice "'file' did not exist on 'ref'" message and redirect back to the repo root, instead of producing a hard "404: Page not found" because it didn't match a route (current behaviour).

References

See #590919 (closed) (this MR shall close that issue), and #590919 (comment 3107565260) for analysis/decision on how to fix.

How to set up and validate locally

  1. Create a file in a repository called abc/def/ghi.md. In it, write Hello [world](../../world.md). Don't have a file called world.md at the root of the repository, that'd spoil the repro!
  2. Look at the rendered world link. It should be something like http://gdk.test:3000/your/repo/-/world.md. This isn't a valid GitLab URL!
  3. Click it! You should see a "404: Page not found" page.
  4. Check this branch out.
  5. Maybe restart your GDK if you're feeling unlucky.
  6. Go back to ghi.md and edit its content; change Hello to Howdy or similar. (We want to make sure there's no cache in the way.)
  7. Look at the rendered world link now. It should be something like http://gdk.test:3000/your/repo/-/blob/main/world.md. This is a valid GitLab URL!
  8. Click it. You should be redirected to the repository root page, with a pop-up error that says '"world.md" did not exist on "main"'.
  9. This is the way.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading