URL 部分规范术语
URL parts canonical terminology
我一直在阅读,似乎 URL 部分没有非常连贯和完全接受的术语。真的吗?我想知道 URL 部件术语有哪些标准。什么是最常见的?有什么公认的标准吗?
我发现了以下内容:
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
window.location
来自 Javascript 在浏览器上
protocol://username:password@hostname:port/pathname?search#hash
-----------------------------href------------------------------
-----host----
----------- origin -------------
protocol
- URL 的协议方案,包括最后的 ':'
hostname
- 域名
port
- 端口号
pathname
- /路径名
search
- ?参数
hash
- #fragment_identifier
username
- 域名前指定的用户名
password
- 域名前指定的密码
href
- 整个URL
origin
- 协议://hostname:port
host
- hostname:port
- NodeJS,模块
url
在带有 URL 的行上方您会看到节点的 url
模块旧 API,而在行下方您会看到新的 API。节点似乎从 RFC 标准术语转变为对浏览器更友好的标准术语,即类似于浏览器的 windows.location
.
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ href │
├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤
│ protocol │ │ auth │ host │ path │ hash │
│ │ │ ├─────────────────┬──────┼──────────┬────────────────┤ │
│ │ │ │ hostname │ port │ pathname │ search │ │
│ │ │ │ │ │ ├─┬──────────────┤ │
│ │ │ │ │ │ │ │ query │ │
" https: // user : pass @ sub.example.com : 8080 /p/a/t/h ? query=string #hash "
│ │ │ │ │ hostname │ port │ │ │ │
│ │ │ │ ├─────────────────┴──────┤ │ │ │
│ protocol │ │ username │ password │ host │ │ │ │
├──────────┴──┼──────────┴──────────┼────────────────────────┤ │ │ │
│ origin │ │ origin │ pathname │ search │ hash │
├─────────────┴─────────────────────┴────────────────────────┴──────────┴────────────────┴───────┤
│ href │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
- 来自 Matt Cutts
的高排名 article
URL: http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#00h02m30s
- 协议是 http。其他协议包括https、ftp等
- 主机或主机名是 video.google.co.uk。
- 子域是视频。
- 域名为google.co.uk.
- 顶级域或 TLD 是 uk。英国域也称为国家代码顶级域或 ccTLD。对于 google.com,TLD 将是 com.
- 二级域名(SLD)为co.uk。
- 端口为 80,这是 Web 服务器的默认端口。其他端口也是可能的;例如,Web 服务器可以侦听端口 8000。端口是80的时候,一般人都漏掉了。
- 路径是/videoplay。路径通常是指网络服务器上的文件或位置,例如/directory/file.html
- 这个URL有参数。一个参数的名称是 docid,该参数的值是 7246927612831078230。URLs 可以有很多参数。参数以问号 (?) 开头,并以与号 (&) 分隔。
我的一些担忧:
window.location
是标准还是基于标准?
我应该叫 http://
protocol
还是 scheme
?
我应该说host
还是authority
?
为什么 window.location
和节点都没有 TLD 或其他域部分的属性(如果可用)?
hostname
(example.com)和example.com的术语区别
host
(example.com:8080) 是否成立?
对于节点 origin
不包括 username:password@
而对于 windows.location
它包括
我想在我的代码中遵循完善的标准或最佳实践。
术语取决于您使用的架构 style/technology。
我更喜欢 REST 风格来识别我的不同部分 url REST URI Standard
但我再说一遍,没有单一的通用标准来表示URL
Java java.net.URL follows RFC 2396 这是 RFC 3986 的旧版本。
Python 的 urlparse 也遵循 RFC 3986,除了使用 netloc
而不是 authority
可能是出于遗留原因。
换句话说,我会遵循 RFC 3986。
URI 标准是 STD 66. This is currently mapped to RFC 3986。
所以对于通用的URI语法,这些术语是权威的,目前:
scheme
authority
userinfo
host
port
path
query
fragment
我一直在阅读,似乎 URL 部分没有非常连贯和完全接受的术语。真的吗?我想知道 URL 部件术语有哪些标准。什么是最常见的?有什么公认的标准吗?
我发现了以下内容:
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
window.location
来自 Javascript 在浏览器上
protocol://username:password@hostname:port/pathname?search#hash
-----------------------------href------------------------------
-----host----
----------- origin -------------
protocol
- URL 的协议方案,包括最后的 ':'hostname
- 域名port
- 端口号pathname
- /路径名search
- ?参数hash
- #fragment_identifierusername
- 域名前指定的用户名password
- 域名前指定的密码href
- 整个URLorigin
- 协议://hostname:porthost
- hostname:port
- NodeJS,模块
url
在带有 URL 的行上方您会看到节点的 url
模块旧 API,而在行下方您会看到新的 API。节点似乎从 RFC 标准术语转变为对浏览器更友好的标准术语,即类似于浏览器的 windows.location
.
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ href │
├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤
│ protocol │ │ auth │ host │ path │ hash │
│ │ │ ├─────────────────┬──────┼──────────┬────────────────┤ │
│ │ │ │ hostname │ port │ pathname │ search │ │
│ │ │ │ │ │ ├─┬──────────────┤ │
│ │ │ │ │ │ │ │ query │ │
" https: // user : pass @ sub.example.com : 8080 /p/a/t/h ? query=string #hash "
│ │ │ │ │ hostname │ port │ │ │ │
│ │ │ │ ├─────────────────┴──────┤ │ │ │
│ protocol │ │ username │ password │ host │ │ │ │
├──────────┴──┼──────────┴──────────┼────────────────────────┤ │ │ │
│ origin │ │ origin │ pathname │ search │ hash │
├─────────────┴─────────────────────┴────────────────────────┴──────────┴────────────────┴───────┤
│ href │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
- 来自 Matt Cutts 的高排名 article
URL: http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#00h02m30s
- 协议是 http。其他协议包括https、ftp等
- 主机或主机名是 video.google.co.uk。
- 子域是视频。
- 域名为google.co.uk.
- 顶级域或 TLD 是 uk。英国域也称为国家代码顶级域或 ccTLD。对于 google.com,TLD 将是 com.
- 二级域名(SLD)为co.uk。
- 端口为 80,这是 Web 服务器的默认端口。其他端口也是可能的;例如,Web 服务器可以侦听端口 8000。端口是80的时候,一般人都漏掉了。
- 路径是/videoplay。路径通常是指网络服务器上的文件或位置,例如/directory/file.html
- 这个URL有参数。一个参数的名称是 docid,该参数的值是 7246927612831078230。URLs 可以有很多参数。参数以问号 (?) 开头,并以与号 (&) 分隔。
我的一些担忧:
window.location
是标准还是基于标准?我应该叫
http://
protocol
还是scheme
?我应该说
host
还是authority
?为什么
window.location
和节点都没有 TLD 或其他域部分的属性(如果可用)?hostname
(example.com)和example.com的术语区别host
(example.com:8080) 是否成立?对于节点
origin
不包括username:password@
而对于windows.location
它包括
我想在我的代码中遵循完善的标准或最佳实践。
术语取决于您使用的架构 style/technology。
我更喜欢 REST 风格来识别我的不同部分 url REST URI Standard
但我再说一遍,没有单一的通用标准来表示URL
Java java.net.URL follows RFC 2396 这是 RFC 3986 的旧版本。
Python 的 urlparse 也遵循 RFC 3986,除了使用 netloc
而不是 authority
可能是出于遗留原因。
换句话说,我会遵循 RFC 3986。
URI 标准是 STD 66. This is currently mapped to RFC 3986。
所以对于通用的URI语法,这些术语是权威的,目前:
scheme
authority
userinfo
host
port
path
query
fragment