URLPattern: password 属性
注意:此功能在 Web Workers 中可用。
URLPattern
接口的 password
只读属性是一个字符串,其中包含用于匹配 URL 密码部分的模式。
值
字符串。
示例
基本用法
以下示例创建一个 URLPattern
对象,其 password
部分为 correct-horse-battery{-staple}?
,并记录该属性。此模式匹配密码 correct-horse-battery
和 correct-horse-battery-staple
。
js
const pattern = new URLPattern({ password: "correct-horse-battery{-staple}?" });
console.log(pattern.password); // 'correct-horse-battery{-staple}?'
console.log(pattern.test("https://user:correct-horse-battery@example.com")); // true
规范
规范 |
---|
URL 模式 # dom-urlpattern-password |
浏览器兼容性
加载中…