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

can't update url protocol when old protocol include '+' #39732

Closed
bluelovers opened this issue Aug 11, 2021 · 5 comments
Closed

can't update url protocol when old protocol include '+' #39732

bluelovers opened this issue Aug 11, 2021 · 5 comments
Labels
whatwg-url Issues and PRs related to the WHATWG URL implementation.

Comments

@bluelovers
Copy link

bluelovers commented Aug 11, 2021

Version

v16.6.1

Platform

windows 10 x64

Subsystem

No response

What steps will reproduce the bug?

let u = new URL( 'git+https://url-fake-hostname/zh-TW/scripts')

console.log(u)

u.protocol = 'http:';

console.assert(u.protocol !== 'git+https:', u.protocol)

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

u.protocol = 'http:'

What do you see instead?

u.protocol = 'git+https:'

image

Additional information

in google chrome it can be update

image

https://stackoverflow.com/questions/68738015/why-cant-update-url-protocol-when-old-protocol-include-in-nodejs

@targos targos added the whatwg-url Issues and PRs related to the WHATWG URL implementation. label Aug 11, 2021
@targos
Copy link
Member

targos commented Aug 11, 2021

The behavior is correct according to the URL spec: https://url.spec.whatwg.org/#ref-for-scheme-state

If url’s scheme is not a special scheme and buffer is a special scheme, then return.

Because http is special scheme, and git+https isn't.

@bluelovers
Copy link
Author

but Firefox, edge, chrome all support change it from git+https: to http:

@targos
Copy link
Member

targos commented Aug 11, 2021

If they all support it, it's probably worth opening an issue in the spec repo: https://github.com/whatwg/url/issues

/cc @TimothyGu

@bluelovers
Copy link
Author

another issue is origin is string 'null' in this case

bluelovers added a commit to bluelovers/ws-http that referenced this issue Aug 11, 2021
@anonrig
Copy link
Member

anonrig commented Feb 3, 2023

I agree with @targos. This is the correct behavior. URL spec mentions that in scheme state:

If url’s scheme is a special scheme and buffer is not a special scheme, then return.

another issue is origin is string 'null' in this case

@bluelovers Origin definition in the URL spec states that, if the scheme is not special or not blob, it will always return a new opaque origin (which is null). Referencing: https://url.spec.whatwg.org/#origin

I'm closing this issue. Please open a new issue, if you think there is a misinterpretation of the spec.

@anonrig anonrig closed this as completed Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

No branches or pull requests

3 participants