Skip to content

Commit 4398750

Browse files
committed
Don't pre-concatenate path
1 parent a137c23 commit 4398750

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/librustdoc/html/layout.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ crate fn render<T: Print, S: Print>(
114114
{after_content}\
115115
<div id=\"rustdoc-vars\" data-root-path=\"{root_path}\" data-current-crate=\"{krate}\"></div>
116116
<script src=\"{static_root_path}main{suffix}.js\"></script>\
117-
{static_extra_scripts}\
118117
{extra_scripts}\
119118
<script defer src=\"{root_path}search-index{suffix}.js\"></script>\
120119
</body>\
@@ -135,22 +134,23 @@ crate fn render<T: Print, S: Print>(
135134
root_path = page.root_path,
136135
css_class = page.css_class,
137136
logo = {
138-
let p = format!("{}{}", page.root_path, layout.krate);
139-
let p = ensure_trailing_slash(&p);
140137
if layout.logo.is_empty() {
141138
format!(
142-
"<a href='{path}index.html'>\
139+
"<a href='{root}{path}index.html'>\
143140
<div class='logo-container rust-logo'>\
144141
<img src='{static_root_path}rust-logo{suffix}.png' alt='logo'></div></a>",
145-
path = p,
142+
root = page.root_path,
143+
path = ensure_trailing_slash(&layout.krate),
146144
static_root_path = static_root_path,
147145
suffix = page.resource_suffix
148146
)
149147
} else {
150148
format!(
151-
"<a href='{}index.html'>\
152-
<div class='logo-container'><img src='{}' alt='logo'></div></a>",
153-
p, layout.logo
149+
"<a href='{root}{path}index.html'>\
150+
<div class='logo-container'><img src='{logo}' alt='logo'></div></a>",
151+
root = page.root_path,
152+
path = ensure_trailing_slash(&layout.krate),
153+
logo = layout.logo
154154
)
155155
}
156156
},
@@ -194,7 +194,7 @@ crate fn render<T: Print, S: Print>(
194194
))
195195
.collect::<String>(),
196196
suffix = page.resource_suffix,
197-
static_extra_scripts = page
197+
extra_scripts = page
198198
.static_extra_scripts
199199
.iter()
200200
.map(|e| {
@@ -204,17 +204,13 @@ crate fn render<T: Print, S: Print>(
204204
extra_script = e
205205
)
206206
})
207-
.collect::<String>(),
208-
extra_scripts = page
209-
.extra_scripts
210-
.iter()
211-
.map(|e| {
207+
.chain(page.extra_scripts.iter().map(|e| {
212208
format!(
213209
"<script src=\"{root_path}{extra_script}.js\"></script>",
214210
root_path = page.root_path,
215211
extra_script = e
216212
)
217-
})
213+
}))
218214
.collect::<String>(),
219215
filter_crates = if layout.generate_search_filter {
220216
"<select id=\"crate-search\">\

0 commit comments

Comments
 (0)