8000 Fix require on network share path by codebytere · Pull Request #12282 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
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

Fix require on network share path #12282

Merged
merged 2 commits into from
Mar 15, 2018
Merged

Fix require on network share path #12282

merged 2 commits into from
Mar 15, 2018

Conversation

codebytere
Copy link
Member
@codebytere codebytere commented Mar 14, 2018

Closes #12268.
Closes #3043.

This PR fixes an issue such that when an Electron executable is run through a server/network share path formatted as\\SERVERNAME\appdir\appname.exe, require runs into

Cannot find module

errors.

/cc @ckerr

@codebytere codebytere requested a review from a team March 14, 2018 23:45
@ckerr ckerr requested a review from alexeykuzmin March 15, 2018 00:02
pathname = `//${loc.host}/${pathname}`
}
} else {
pathname = loc.pathname
8000 Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please initialise let pathname with window.location.pathname and do all Windows specific stuff below it? Like this:

const location = window.location
let pathname = location.pathname

if (process.platform === 'win32') {
  // Oh crap
  ...
}

pathname = loc.pathname.substr(1)
}

if (loc.hostname.length > 0 && globalPaths[0].startsWith('\\')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have a comment describing (or a link to) an issue this addresses.
Or a simple variable could help too:

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

@trop
Copy link
Contributor
trop bot commented Mar 15, 2018

We have automatically backported this PR to "1-8-x", please check out #12286

@trop
Copy link
Contributor
trop bot commented Mar 15, 2018

We have automatically backported this PR to "2-0-x", please check out #12287

@trop trop bot added merged/2-0-x and removed target/2-0-x labels Mar 15, 2018
@MarshallOfSound MarshallOfSound deleted the windows-require-fix branch March 15, 2018 03:26
sethlu pushed a commit to sethlu/electron that referenced this pull request May 3, 2018
* first pass at server/network require fix

* refactor for clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants
0