mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Backport (2-0-x) - Fix require on network share path (#12287)
* first pass at server/network require fix * refactor for clarity
This commit is contained in:
@@ -141,7 +141,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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user