headers icon indicating copy to clipboard operation
headers copied to clipboard

Origin::try_from_parts shouldn't include default port values

Open jdm opened this issue 7 years ago • 3 comments

If the scheme is http and the port is 80, or https and 443, the port should not be included by default. Per testing in https://github.com/servo/servo/issues/22090#issuecomment-443602332 this is not web compatible.

jdm avatar Dec 03 '18 06:12 jdm

On the other hand, I guess this can be dealt with by the caller by passing a None value for the port when desired.

jdm avatar Dec 03 '18 06:12 jdm

Would it be expected that the "default" port is just thrown away? For instance:

let origin = Origin::try_from_parts("https", "duckduckgo.com", 443).unwrap();
// Which should be correct?
assert_eq!(origin.port(), Some(443));
assert_eq!(origin.port(), None);

Since the argument can be passed explicitly, part of me thinks it'd be more confusing if the port sometimes wasn't included.

seanmonstar avatar Dec 10 '18 23:12 seanmonstar

Would it be expected that the "default" port is just thrown away?

That's what rust-url does, so yes.

notriddle avatar Jan 03 '19 19:01 notriddle