Add tooling to reduce relative root url bugs

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

It's possible to run GitLab with a relative url root: https://docs.gitlab.com/ee/install/relative_url.html

Bugs related to this feature are often not caught before they reach customers. Recent examples where a customer had to fix these themselves:

QA tests currently run with the root url configured, so there is some coverage to catch bugs, but the extent of these is not total, nor would we want it to be since we follow a testing levels approach.

Proposal

Add additional ways of safeguarding against relative root url bugs. Some very rough ideas (please add more!):

  • Linting for hardcoded urls in haml + vue templates.
    • A constrained use case like href="" or axios.get could be a manageable start.
  • Disallow axios.get in favour of Api.whatever.
  • Run unit tests with a relative url configured (in the gon object), forcing unit test authors to include the relative url in their assertions. (might not add anything since it would require specific tests to be there already)

None of these ideas would provide total coverage but a combined approach could at least reduce the likelihood of such bugs to occur.

Edited by 🤖 GitLab Bot 🤖