Fix require on network share path (#12282)
* first pass at server/network require fix * refactor for clarity
This commit is contained in:
parent
1f8de33e75
commit
9aeb61181a
1 changed files with 12 additions and 1 deletions
|
@ -141,7 +141,18 @@ if (nodeIntegration === 'true') {
|
||||||
|
|
||||||
// Set the __filename to the path of html file if it is file: protocol.
|
// Set the __filename to the path of html file if it is file: protocol.
|
||||||
if (window.location.protocol === 'file:') {
|
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.__filename = path.normalize(decodeURIComponent(pathname))
|
||||||
global.__dirname = path.dirname(global.__filename)
|
global.__dirname = path.dirname(global.__filename)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue