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]);
}
refs
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!