if (/\/art-8\/?$/.test(location.pathname)) {
...
}
will match any pathname ending in /art-8
or /art-8/
. Or splitting the pathname into its component parts:
var parts = location.pathname.split('/').slice(1);
if(parts[parts.length - 1] == '') parts = parts.slice(0, -1);
if(parts[parts.length - 1] == 'art-8') {
...
}
EDIT: If art-8
need not be at the end, but there is a slash before it:
if (/\/art-8/.test(location.pathname)) {
...
}
Or if there isn't necessarily a slash before it, but you just want to look for art-8
without a c
before it (pathname will always begin with a slash, so there will always be at least one character before and this will work):
if (/[^c]art-8/.test(location.pathname)) {
...
}
Note that pathname does not include the ?
and what comes after it, so even the first two examples I gave should work for the specific example URL you gave if you add .asp
just after the 8
.