fix: support file: and chrome-extension: protocols in client #2954
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.
For Bugs and Features; did you add new tests?
Yes, I added tests to check if the protocol was changed, it is poking at variables inside of WebSocket and SockJS though, this is probably not the most stable way to do this, but I am not sure how to mock those or if that is even necessary.
Motivation / Use-Case
When using node-webkit, or electron, the protocol can be
file:
orchrome-extension:
, causing the websocket or sockjs to try to connect to an incorrect url, for example:file://localhost:8080/ws
orchrome-extension://localhost:8080/ws
.This PR changes it to the correct behaviour.
Breaking Changes
This PR should not be a breaking change.
Additional Info
I just noticed I also replace
https
withws
, this should probably be an extra case where it is replaced withwss
.EDIT: I removed the https case