pathname url-part всегда начинается с /. Если вы пропустите /в своем регулярном выражении, совпадение не удалось < /p>
API шаблона URL (PathName Matching) < /p>
< /blockquote>
Let Lead Slas pathname)
The pathname options is an options struct with delimiter code point set "/" and prefix code point set to "/"
WHATWG (pathname options)
Why is the output true if the string doesn't Начните с " /"? < /p>
Код: Выделить всё
console.log(
new URLPattern({pathname: '*/books'}).test({pathname: '/api/v1/books'})
)Это скрытая функция или я пропустил какой -то момент в MDN или в WhatWg?
Подробнее здесь: https://stackoverflow.com/questions/797 ... f-pathname
Мобильная версия