zoukankan      html  css  js  c++  java
  • URI与URL

    背景

    项目需要自己构造一个URI Scheme,但是不知道URI是什么,以及Scheme的命名方式,所以找了以下资料。

    资料

    URL非常好理解,因为很常见,它是用于网络上定位互联网上Web资源的,如网上的某个图片,某个mp3或某个H5页面的地址。
    举例:http://www.baidu.com/img/bdlogo.png

    而URI和URL并不等同,定义如下

    URI:Uniform resource identifier 统一资源标识符

    URL:Uniform resource locator 统一资源定位符

    维基百科:

    The most common form of URI is the uniform resource locator (URL)

    所以URL是URI的子集

    URI是一个资源定位符,并不一定是网络上的,它可以是你本机上的。

    举例:

    https://example.org/absolute/URI/with/absolute/path/to/resource.txt
    ftp://example.org/resource.txt
    ed2k://|file|%5BMAC%E7%89%88%E6%9E%81%E5%9

    URI Scheme是一个规范,所以符合它的规范的都可以称之为URI Scheme,所以我们也可以设计自己的scheme。

    scheme:[//[user:password@]domain[:port]][/]path[?query][#fragment]

    <scheme name> : <hierarchical part> [ ? <query> ] [ # <fragment> ]

    <scheme name>:scheme的名称,对于上面3个scheme,它们scheme名分别是http, ftp, ed2k(电驴协议)

    <hierarchical part>:路径名,一般为authority+path,见下图即知

    <query>:查询字段,一般为键值对,参考URL即知

    <fragment>:可选字段,经常看到网页中用来回到顶部的就是这个啦

    关于Scheme的命名方式,维基百科如是说 

    The scheme consists of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus (+), period (.), or hyphen (-). Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters.

  • 相关阅读:
    zoj 3627#模拟#枚举
    Codeforces 432D Prefixes and Suffixes kmp
    hdu 4778 Gems Fight! 状压dp
    CodeForces 379D 暴力 枚举
    HDU 4022 stl multiset
    手动转一下田神的2048
    【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律
    poj 3254 状压dp
    C++中运算符的优先级
    内存中的数据对齐
  • 原文地址:https://www.cnblogs.com/chenyg32/p/4790365.html
Copyright © 2011-2022 走看看