url.password


获取和设置网址的密码部分。

【Gets and sets the password portion of the URL.】

const myURL = new URL('https://abc:xyz@example.com');
console.log(myURL.password);
// Prints xyz

myURL.password = '123';
console.log(myURL.href);
// Prints https://abc:123@example.com/ 

password 属性中分配的值包含无效的 URL 字符是 百分比编码。需要进行百分号编码的字符选择可能与 url.parse()url.format() 方法产生的结果略有不同。

【Invalid URL characters included in the value assigned to the password property are percent-encoded. The selection of which characters to percent-encode may vary somewhat from what the url.parse() and url.format() methods would produce.】