Now I have a URL which is
var url1 = 'www.test.com/test'
If I use
url1.indexOf('/test') !== -1 // will return true
What if I change the URL to
var url2 = 'www.test.com/test123'
url2.indexOf('/test') !== -1. // still return true
What I want to do is only this pattern /test can return true otherwise return false, for example /test123 or /test12312
www.test.com/test/1234orwww.test.com/abc/test. And that’s not really a URL btw.var hasTest = url1.split("/").slice(1).some( s => s == "test" );