8000 Backport (1-8-x) - Fix require on network share path by trop[bot] · Pull Request #12286 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Backport (1-8-x) - Fix require on network share path #12286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
13 changes: 12 additions & 1 deletion lib/renderer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,18 @@ if (nodeIntegration === 'true') {

// Set the __filename to the path of html file if it is file: protocol.
if (window.location.protocol === 'file:') {
var pathname = process.platform === 'win32' && window.location.pathname[0] === '/' ? window.location.pathname.substr(1) : window.location.pathname
const location = window.location
let pathname = location.pathname

if (process.platform === 'win32') {
if (pathname[0] === '/') pathname = pathname.substr(1)

const isWindowsNetworkSharePath = location.hostname.length > 0 && globalPaths[0].startsWith('\\')
if (isWindowsNetworkSharePath) {
pathname = `//${location.host}/${pathname}`
}
}

global.__filename = path.normalize(decodeURIComponent(pathname))
global.__dirname = path.dirname(global.__filename)

Expand Down
0