Skip to content

Commit

Permalink
Disable browser history API on file:/ URLs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
badboy committed Sep 14, 2015
1 parent 664a459 commit 7f5ec6c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
}

function browserSupportsHistoryApi() {
return window.history && typeof window.history.pushState === "function";
return document.location.protocol != "file:" &&
window.history && typeof window.history.pushState === "function";
}

function highlightSourceLines(ev) {
Expand Down

0 comments on commit 7f5ec6c

Please sign in to comment.