URLs with all-numerical anchors break rendering of table of contents
Description
If someone lands on any page on GitLab Docs, and the URL has a fully numerical anchor, a browser error occurs and the Table of Contents doesn't render properly.
For example:
- https://docs.gitlab.com/ee/user/project/issues/design_management.html - Causes no browser error and the ToC looks fine.
- https://docs.gitlab.com/ee/user/project/issues/design_management.html#1234 - Causes a browser error and the ToC is frozen in place.
Interestingly, this can affect the ToC in an extra way on a page where tier badges are used. For example:
-
https://docs.gitlab.com/ee/user/project/issue_board.html - Inline tier badges do not appear in the ToC.
-
https://docs.gitlab.com/ee/user/project/issue_board.html#1234 - Inline tier badges appear in the ToC:
Note that starting the anchor with a letter fixes the problem:
- https://docs.gitlab.com/ee/user/project/issue_board.html#a1234 - No browser error, no inline tier badges in the ToC.
This might seem unimportant, but until recently a page had all-numerical anchors that were correct and could be linked to:
- https://docs.gitlab.com/15.8/ee/user/group/import/index.html#140
- https://docs.gitlab.com/15.8/ee/user/group/import/index.html#130
I doubt this is prevalent, and it's fixed in %15.9: https://docs.gitlab.com/ee/user/group/import/index.html#compatibility, but for robustness we should probably make it so that correct or incorrect all-numerical URLs with anchors don't cause a rendering problem.
Steps to reproduce
- Browse to any page and add
#1234
to the URL. - Submit that to the browser so the page is loaded from the URL.
Actual result
Rendering of ToC is broken.
Expected result
Site should tolerate these anchors in URLs.
Further details
It turns out some punctuation can cause this problem too: https://docs.gitlab.com/ee/user/group/import/index.html#com;patibility, so perhaps we need to tolerate some malformed anchor tags (I don't think that URL would every be considered valid).