Closed Bug 1326394 Opened 8 years ago Closed 10 months ago

URL.host does not work correctly for custom protocol URLs

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: emk, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-edge, Whiteboard: [necko-backlog])

Spun out from bug 1323683. Steps to reproduce: var url = new URL("scheme://test/bla/stuff?query#ref"); url.host Actual result: "" Expected result: "test" Chrome fails as well, but Edge works as expected.
Depends on: 1326520
Whiteboard: [parity-edge] → [necko-backlog][parity-edge]
Priority: -- → P1
Priority: P1 → P3
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Keywords: parity-edge
Whiteboard: [necko-backlog][parity-edge] → [necko-backlog]
Severity: normal → S3

This works in Node.js 18, that follow the same spec (https://url.spec.whatwg.org/)

var url = new URL("scheme://test/bla/stuff?query#ref");
undefined
url.host
'test'

I know that Chrome/Edge has the same behavior. I don't know if Node.js has it right or not.

But parsing other things is crucial for some applications, like parsing RTSP url which are clearly defined. Relying on https://github.com/unshiftio/url-parse is completely discouraged, but I have no other solution for having the host/hostname of rtsp://192.168.0.1/path/1 for now.

This seems to be a very long standing bug. See https://bugs.chromium.org/p/chromium/issues/detail?id=869291 that references https://bugs.chromium.org/p/chromium/issues/detail?id=660384 as parent.

An actual test page for this use case (with scheme://) can be see on https://jsdom.github.io/whatwg-url/#url=&base=c2NoZW1lOi8vdGVzdC9ibGEvc3R1ZmY/cXVlcnkjcmVm

More troubling is that some non-special protocols are recognized, such as ssh:// (Firefox only) https://jsdom.github.io/whatwg-url/#url=&base=c3NoOi8vZXhhbXBsZS5jb20vcGF0aA==

For now, I rely on the implementation in https://github.com/jsdom/whatwg-url The package is quite small, and URL really works.

See Also: → 1839303
Blocks: url
Depends on: 1603699
Duplicate of this bug: 1839303
Duplicate of this bug: 1864939

Fixed by bug 1603699.

Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.