Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2c78a3

Browse files
theozaurusposva
authored andcommittedJun 6, 2019
fix: apps loaded from Windows file shares not mapped to network drives (#2774)
When loading an application from a Windows file share (not mapped to a network letter), Chrome will throw an error ("cannot be created in a document with origin 'null'") when `replaceState` is called. This happens because while `protocol` is `file:` and `host` is `vboxsvr` the `origin` is `file://` as opposed to `file://vboxsvr`. This means the absolute path is not created correctly. Only Windows shares that are not mapped to a drive letter are affected. If a drive letter is mapped then while origin will still be `file://`, pathname will include the information instead (e.g. `/Z:/dist/index.html`) This code removes the reliance on the origin attribute and calculates the absolute path from `protocol` and `host`.
1 parent ffcc518 commit c2c78a3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/util/scroll.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ const positionStore = Object.create(null)
99
export function setupScroll () {
1010
// Fix for #1585 for Firefox
1111
// Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
12-
window.history.replaceState({ key: getStateKey() }, '', window.location.href.replace(window.location.origin, ''))
12+
// Fix for #2774 Support for apps loaded from Windows file shares not mapped to network drives
13+
const protocolAndPath = window.location.protocol + '//' + window.location.host
14+
const absolutePath = window.location.href.replace(protocolAndPath, '')
15+
window.history.replaceState({ key: getStateKey() }, '', absolutePath)
1316
window.addEventListener('popstate', e => {
1417
saveScrollPosition()
1518
if (e.state && e.state.key) {

0 commit comments

Comments
 (0)
Failed to load comments.