Skip to content

Commit 7f5ec6c

Browse files
committed
Disable browser history API on file:/ URLs
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 #25953
1 parent 664a459 commit 7f5ec6c

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)