Repository navigation
fix(sio-client): default to https for a URL with no scheme in Node.js and React Native - #5626
Open
mark1russell7 wants to merge 1 commit into
Open
mark1russell7 wants to merge 1 commit into
mark1russell7 wants to merge 1 commit into
Conversation
… and React Native Without a global location object, loc was false, so the check "undefined" !== typeof loc was always true, and a URL with no scheme became "undefined//host" instead of "https://host".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The kind of change this PR does introduce
Current behavior
When there is no
locationobject,locisfalse, so the check"undefined" !== typeof locis always true, andurl("example.com:3000")gives"undefined//example.com:3000". The fallback tohttps://never runs.New behavior
The check is
if (loc), so the fallback tohttps://runs when there is nolocationobject.A test is added in
test/url.ts("works with no protocol and no location (Node.js and React Native)"). It is skipped when alocationobject exists (the browser tests).The tests ran in GitHub Actions (Node.js 24.22.2 on Linux): the new tests with the
libfolder of upstream main (before), then with this change (after), thennpm testof socket.io-client with this change:The failures before the change:
Other information (e.g. related issues)
Closes #5620
This PR was prepared with AI assistance (Claude). The tests above were run before and after the change, with the results above.
🤖 Generated with Claude Code