Skip to content

CI linting: Detect wrong relative URLs with `sites/*/source/` prefix

Describe the problem

With the monorepo refactor, the path on disk is not the same as with relative URLs in Markdown text. Sometimes you'll copy paste this path and it slips through review into production. I've seen it with !71749 (merged) and it may occur in other places too.

-##### For [Incident Communications Plans, please check out this handbook page](sites/handbook/source/handbook/marketing/corporate-marketing/incident-communications-plan/index.html.md).
+##### For [Incident Communications Plans, please check out this handbook page](/handbook/marketing/corporate-marketing/incident-communications-plan/).

Proposed Solution

Our CI linting checks can help prevent wrong URLs from being inserted, e.g. with a regex like this: \[.*\]\((sites\/.*\/source)\/.*\).

image

Advanced helpers

Additional logic could also automatically add a suggestion to the MR via API call, and allow the author/reviewer to apply this.

The case above needs 2 proposed fixes:

  • The prefix removal
  • the index.html.md suffix removal

What do you think @laurenbarker @cwoolley-gitlab? :)

/cc @gl-website