3 ms·
To the OP: I would suggest normalising the protocol. Your examples show that you retain the case from the raw data: "protocol": "HTTP" "protocol": "htt
by darrenf 7y ago
To the OP: I would suggest normalising the protocol. Your examples show that you retain the case from the raw data:
"protocol": "HTTP"
"protocol": "https"
As it stands, users will end up normalising by themselves and you can save them the effort. FWIW this part is typically called the scheme, not protocol (e.g. Perl has `URI::Find::Schemeless` which performs a similar task)
URI = scheme:[//authority]path[?query][#fragment]
See https://tools.ietf.org/html/rfc3986#section-3 https://tools.ietf.org/html/rfc3986#section-3
To that end, you might also want to consider adding support for fragments. :)
- felixfbecker 7y agoWell in JS, it's called protocol https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol https://developer.mozilla.org/en-US/docs/Web/API/URL/protoco...
- JoBrad 7y agoNode calls it a protocol scheme. https://nodejs.org/dist/latest-v12.x/docs/api/url.html#url_urlobject_protocol https://nodejs.org/dist/latest-v12.x/docs/api/url.html#url_u...
- noobiemcfoob 7y agoCongratulations! You're all right!
- darrenf 7y agoInteresting, thanks. I have virtually zero JS experience so didn't know that, and were I to try and pick it up this would've been a surprise to me - I naively assumed it would use the same terminology as the RFC and the libraries in languages with which I am familiar (rust, golang, python, perl). A quick look for the URI data type in a handful of other languages shows they also use "scheme". JS appears to be the outlier here.
- seandougall 7y agoIn particular, the scheme doesn't necessarily refer to a protocol (e.g. application-specific schemes like `chrome:` that don't involve network access at all).