首页 > 试题广场 >

如下题正确的是?

[单选题]
如下题正确的是?

  • "https%3A//www.bilibili.com/text.html"
    
    "https://www.bilibili.com/text.html"
    
    "https%3A%2F%2Fwww.bilibili.com%2Ftext.html"
  • "https://www.bilibili.com/text.html"
    
    "https%3A//www.bilibili.com/text.html"
    
    "https%3A%2F%2Fwww.bilibili.com%2Ftext.html"
  • "https%3A%2F%2Fwww.bilibili.com%2Ftext.html"
    
    "https%3A//www.bilibili.com/text.html"
    
    "https://www.bilibili.com/text.html"
  • "https%3A//www.bilibili.com/text.html"
    
    "https%3A%2F%2Fwww.bilibili.com%2Ftext.html"
    
    "https://www.bilibili.com/text.html"
encodeURI:可把字符串作为 URI 进行编码。
对以下在 URI 中具有特殊含义的 ASCII 标点符号,encodeURI() 函数是不会进行转义的: , / ? : @ & = + $ #
(可以使用 encodeURIComponent() 方法分别对特殊含义的 ASCII 标点符号进行编码。).
encodeURIComponent:可把字符串作为 URI 组件进行编码。
该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ' ( ) 。
对于其他字符(比如 :;/?:@&=+$,# 这些用于分隔 URI 组件的标点符号),都是由一个或多个十六进制的转义序列替换的。
发表于 2020-02-04 17:47:35 回复(0)
escape 函数没有正确的将中文编码,所以实际上在url encode时并没有什么用
encodeURI 和 encodeURIComponent 的区别是只将url的参数编码,还是把url作为一个整体编码,例如:
我们需要在一个网站后面附加一个redirect_uri 的参数时,这个作为参数的url 就显然应该用encodeURIComponent来编码
发表于 2019-12-25 22:05:07 回复(0)