1
Fork 0

rustdoc: fix buggy JS check for absolute URL

The old code did the wrong thing when faced with a crate named "http".
This commit is contained in:
Michael Howell 2023-01-03 19:46:40 -07:00
parent ab10908e8c
commit 49111eced6
11 changed files with 33 additions and 3 deletions

View file

@ -563,7 +563,7 @@ function loadCss(cssUrl) {
onEachLazy(code.getElementsByTagName("a"), elem => {
const href = elem.getAttribute("href");
if (href && href.indexOf("http") !== 0) {
if (href && !/^(?:[a-z+]+:)?\/\//.test(href)) {
elem.setAttribute("href", window.rootPath + href);
}
});