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 hostname resolving on newConnection #384

Closed
wants to merge 1 commit into from
Closed

fix hostname resolving on newConnection #384

wants to merge 1 commit into from

Conversation

svsool
Copy link
Contributor

@svsool svsool commented Jan 24, 2016

correct behaviour when:

  1. window.location.hostname is empty or undefined
  2. window.location.protocol not http or https

I'll get bug with ionic emulate ios because default protocol in WebView is :file and hostname is empty string, hence SockJs url resolve to "http:/sockjs-node" that caused a bug SyntaxError: The URL's scheme must be either 'http:' or 'https:'. 'file:' is not allowed.

@dperetti
Copy link

dperetti commented Feb 4, 2016

The issue affects Electron as well !

var hostname = urlParts.hostname;

if (urlParts.hostname === '0.0.0.0') {
if (window.location.hostname && !!~window.location.protocol.indexOf('http')) {
Copy link
Member

@SpaceK33z SpaceK33z Aug 24, 2016

Choose a reason for hiding this comment

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

Why the check for http here (not saying it is wrong per se)? If it has a valid reason, could you add a comment above? And also please give an example for when the hostname does not exist in the comments.

We get many PR's around the detection of this url, so comments will help other people here.

Copy link
Contributor Author

@svsool svsool Aug 24, 2016

Choose a reason for hiding this comment

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

for example in electron or any other opened local file in browser, protocol === 'file' and hostname = undefined, hence SockJs url resolves to "http:/sockjs-node" that caused a bug SyntaxError: The URL's scheme must be either 'http:' or 'https:'. 'file:' is not allowed, so we need to be sure that protocol contain 'http' part

Copy link
Member

Choose a reason for hiding this comment

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

Could you add that to the code as a comment though? This is not immediately clear, and since there are no tests yet, it's easy for this to get accidentally removed.

@SpaceK33z
Copy link
Member

Other then the comment above and the merge conflict, this looks good. Will merge if you finish this :).

@SpaceK33z
Copy link
Member

Pinging @svsool, are you still interested in finishing this? This would fix a couple of other problems. I could takeover if you don't have the time.

@svsool
Copy link
Contributor Author

svsool commented Sep 6, 2016

Fix it and create another fresh pull #594

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants