URL字符串是结构化的字符串,包含多个含义不同的组成部分。解析字符串后返回的URL对象,每个属性对应字符串的各个组成部分。
┌────────────────────────────────────────────────────────────────────────────────────────────────┐│ 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 │└────────────────────────────────────────────────────────────────────────────────────────────────┘
