URL 部分规范术语

URL parts canonical terminology

我一直在阅读,似乎 URL 部分没有非常连贯和完全接受的术语。真的吗?我想知道 URL 部件术语有哪些标准。什么是最常见的?有什么公认的标准吗?

我发现了以下内容:

  1. RFC3986 section 3

     foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment
      |   _____________________|__
     / \ /                        \
     urn:example:animal:ferret:nose
  1. window.location 来自 Javascript 在浏览器上

protocol://username:password@hostname:port/pathname?search#hash
-----------------------------href------------------------------
                             -----host----
-----------      origin      -------------
  1. 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                                              │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
  1. 来自 Matt Cutts
  2. 的高排名 article

URL: http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#00h02m30s


我的一些担忧:

  1. window.location是标准还是基于标准?

  2. 我应该叫 http:// protocol 还是 scheme

  3. 我应该说host还是authority

  4. 为什么 window.location 和节点都没有 TLD 或其他域部分的属性(如果可用)?

  5. hostname(example.com)和example.com的术语区别 host (example.com:8080) 是否成立?

  6. 对于节点 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