xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

URL parser All In One

URL parser All In One

const url = new URL(`https://admin:1234567890@cdn.xgqfrms.xyz:8080/logo/icon.png?type=icon&id=007#app`);

URL / URI

https://cdn.xgqfrms.xyz:8080/logo/icon.png?type=icon&id=007#app

https://cdn.xgqfrms.xyz/logo/icon.png?type=icon&id=007#app

// const url = new URL(relativeOrAbsolute [, absoluteBase]);


const url = new URL(`https://cdn.xgqfrms.xyz:8080/logo/icon.png?type=icon&id=007#app`);


searchParams

URLSearchParams

for(const item in url.searchParams) {
  console.log(`url.searchParams ${item} =`, item, url.searchParams[item]);
}

URL 路由/访问路径 ✅

URL 虚拟目录 ❌

URL 路由/访问路径 ✅

https://juejin.cn/post/7064747019411128333

refs

https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2020-11-29 18:19  xgqfrms  阅读(135)  评论(3编辑  收藏  举报