📜  url 解析器 js 节点 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:12.793000             🧑  作者: Mango

代码示例1
const myURL = new URL('https://example.org:81/foo');
console.log(myURL.hostname);
// Prints example.org

// Setting the hostname does not change the port
myURL.hostname = 'example.com:82';
console.log(myURL.href);
// Prints https://example.com:81/foo

// Use myURL.host to change the hostname and port
myURL.host = 'example.org:82';
console.log(myURL.href);
// Prints https://example.org:82/foo