Rollup merge of #106437 - notriddle:notriddle/http-url, r=GuillaumeGomez

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:
Matthias Krüger 2023-01-04 23:39:50 +01:00 committed by GitHub
commit 836321effb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);
}
});

View file

@ -33,3 +33,9 @@ goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html"
assert-count: ("#implementors-list .impl", 1)
goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html"
assert-count: ("#implementors-list .impl", 1)
// Now check that the link is properly rewritten for a crate called `http`.
// An older version of rustdoc had a buggy check for absolute links.
goto: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html"
assert-count: ("#implementors-list .impl", 1)
assert-attribute: ("#implementors-list .impl a.trait", {"href": "../http/trait.HttpTrait.html"})

View file

@ -15,6 +15,7 @@ click: "#crate-search"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
@ -39,6 +40,7 @@ click: "#crate-search"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"

View file

@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed.
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 7)
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
// We now switch to mobile mode.
size: (600, 600)

View file

@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "huge_logo")
assert-text: ("#source-sidebar details:first-of-type > summary", "http")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})

View file

@ -2,13 +2,21 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "http"
version = "0.1.0"
[[package]]
name = "implementors"
version = "0.1.0"
dependencies = [
"http",
]
[[package]]
name = "lib2"
version = "0.1.0"
dependencies = [
"http",
"implementors",
]

View file

@ -8,3 +8,4 @@ path = "lib.rs"
[dependencies]
implementors = { path = "./implementors" }
http = { path = "./http" }

View file

@ -0,0 +1,7 @@
[package]
name = "http"
version = "0.1.0"
edition = "2018"
[lib]
path = "lib.rs"

View file

@ -0,0 +1 @@
pub trait HttpTrait {}

View file

@ -5,3 +5,6 @@ edition = "2018"
[lib]
path = "lib.rs"
[dependencies]
http = { path = "../http/" }

View file

@ -10,6 +10,8 @@ impl Whatever for Struct {
type Foo = u8;
}
impl http::HttpTrait for Struct {}
mod traits {
pub trait TraitToReexport {
fn method() {}