这个url解码后为什么还是原来的样子?

https:\u002F\u002Fv2.kwaicdn.com\u002Fupic\u002F2022\u002F11\u002F05\u002F17\u002FBMjAyMjExMDUxNzA2MzdfMjE4MTY4MV84ODAyNDY5MDQ4OF8xXzM=_hd15_B35267cb0a2657012c374e632b1c42829.mp4?pkey=AAW7inBi05mLoR8Z8lVLndNS3SKgjHYxf7hx-my4ntkXZOsejWLkcQSuchTtwOqfkFebQFfPMnT59OFooAUeBmuQDyQRIg-pocqILQp1qV0c0IKoZfnH7tLP5l4jcfJdrm0&tag=1-1673190730-unknown-0-djpv2bxwxd-cb362c3fcf3384c6&clientCacheKey=3xtzmwkcjq3dx8m_hd15.mp4&di=3a3ebf74&bp=10004&tt=hd15&ss=vp
image.png

回复
阅读 650
4 个回答

你的URL没有编码, 何来的解码一说?

URL编码是指用 %xx 代替一些字符, 不是说看着像乱码就是编码.

你的URL里的\u002f 这应该是 / 看着像是json encode, 不是 url encode.

其实应该使用 unicode 解码工具,而不是URL解码,虽然说在控制台里面依旧可以使用 decodeURI()/encoded() 来解码。

decodeURI('https:\u002F\u002Fv2.kwaicdn.com\u002Fupic\u002F2022\u002F11\u002F05\u002F17\u002FBMjAyMjExMDUxNzA2MzdfMjE4MTY4MV84ODAyNDY5MDQ4OF8xXzM=_hd15_B35267cb0a2657012c374e632b1c42829.mp4?pkey=AAW7inBi05mLoR8Z8lVLndNS3SKgjHYxf7hx-my4ntkXZOsejWLkcQSuchTtwOqfkFebQFfPMnT59OFooAUeBmuQDyQRIg-pocqILQp1qV0c0IKoZfnH7tLP5l4jcfJdrm0&tag=1-1673190730-unknown-0-djpv2bxwxd-cb362c3fcf3384c6&clientCacheKey=3xtzmwkcjq3dx8m_hd15.mp4&di=3a3ebf74&bp=10004&tt=hd15&ss=vp')
// 'https://v2.kwaicdn.com/upic/2022/11/05/17/BMjAyMjExMDUxNzA2MzdfMjE4MTY4MV84ODAyNDY5MDQ4OF8xXzM=_hd15_B35267cb0a2657012c374e632b1c42829.mp4?pkey=AAW7inBi05mLoR8Z8lVLndNS3SKgjHYxf7hx-my4ntkXZOsejWLkcQSuchTtwOqfkFebQFfPMnT59OFooAUeBmuQDyQRIg-pocqILQp1qV0c0IKoZfnH7tLP5l4jcfJdrm0&tag=1-1673190730-unknown-0-djpv2bxwxd-cb362c3fcf3384c6&clientCacheKey=3xtzmwkcjq3dx8m_hd15.mp4&di=3a3ebf74&bp=10004&tt=hd15&ss=vp'

但是其实内部先使用了 toString() 方法,也就是说,你直接在控制台输入

'https:\u002F\u002Fv2.kwaicdn.com\u002Fupic\u002F2022\u002F11\u002F05\u002F17\u002FBMjAyMjExMDUxNzA2MzdfMjE4MTY4MV84ODAyNDY5MDQ4OF8xXzM=_hd15_B35267cb0a2657012c374e632b1c42829.mp4?pkey=AAW7inBi05mLoR8Z8lVLndNS3SKgjHYxf7hx-my4ntkXZOsejWLkcQSuchTtwOqfkFebQFfPMnT59OFooAUeBmuQDyQRIg-pocqILQp1qV0c0IKoZfnH7tLP5l4jcfJdrm0&tag=1-1673190730-unknown-0-djpv2bxwxd-cb362c3fcf3384c6&clientCacheKey=3xtzmwkcjq3dx8m_hd15.mp4&di=3a3ebf74&bp=10004&tt=hd15&ss=vp'
// 'https://v2.kwaicdn.com/upic/2022/11/05/17/BMjAyMjExMDUxNzA2MzdfMjE4MTY4MV84ODAyNDY5MDQ4OF8xXzM=_hd15_B35267cb0a2657012c374e632b1c42829.mp4?pkey=AAW7inBi05mLoR8Z8lVLndNS3SKgjHYxf7hx-my4ntkXZOsejWLkcQSuchTtwOqfkFebQFfPMnT59OFooAUeBmuQDyQRIg-pocqILQp1qV0c0IKoZfnH7tLP5l4jcfJdrm0&tag=1-1673190730-unknown-0-djpv2bxwxd-cb362c3fcf3384c6&clientCacheKey=3xtzmwkcjq3dx8m_hd15.mp4&di=3a3ebf74&bp=10004&tt=hd15&ss=vp'

也会被成功解码的。

decodeURI() - JavaScript | MDN

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏