Skip to content

Commit 6872d13

Browse files
committed
Rollup merge of rust-lang#28400 - badboy:disable-browser-history-on-file, r=steveklabnik
history.pushState is defined, but not working whenever document.origin is "null" (literally that string, not just the null object). This is due to some security considerations and is unlikely to be ever working. For now just disable the usage of the history API when the documentation is accessed through a file:/// URL. See https://code.google.com/p/chromium/issues/detail?id=301210 for a Chrome-specific issue on the history API on file:/// URLs Closes rust-lang#25953
2 parents 655b2ef + 7f5ec6c commit 6872d13

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustdoc/html/static/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
}
5555

5656
function browserSupportsHistoryApi() {
57-
return window.history && typeof window.history.pushState === "function";
57+
return document.location.protocol != "file:" &&
58+
window.history && typeof window.history.pushState === "function";
5859
}
5960

6061
function highlightSourceLines(ev) {

0 commit comments

Comments
 (0)