How make checkUrl
function, that works similar to vue, angular, symfony, laravel? I need check domain host, and path
is there a library?
if (checkUrl('myShop.com/product/:id',url)) {
console.log('matches myShop.com/product/pepsi')
}
if (checkUrl('myShop.com/product/:id/**',url)) {
console.log('matches myShop.com/product/pepsi and myShop.com/product/pepsi/reviews/1/comments')
}
if (checkUrl('ozon.ru/product/:id/**',url)) {
console.log('matches ozon.ru/product/pepsi and ozon.ru/product/pepsi/reviews/1/comments')
}
found library https://github.com/visionmedia/page.js example usage
function checkUrl(pattern, url) {
return new Route(pattern).match(url)
}
if (checkUrl('*ozon.ru/product/:id/**',location.href)) {
console.log('matches ozon.ru/product/pepsi and ozon.ru/product/pepsi/reviews/1/comments')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.