JSFiddle - React, Tailwind, and code Playground

by zedsaid

JavaScript

var current_url = 'http://www.test.com/path/1/4';

var parent_urls = ['http://www.test.com/path/1', 
                   'http://www.test.com/path/2/4', 
                   'http://www.test.com/path/3/4', 
                   'http://www.test.com/path/4/5/3'];

// Check to see if current URL is part of any of the parent URLs
for (var i=0;i<parent_urls.length;i++) {
    parent = parent_urls[i];
    if (current_url.indexOf(parent) != -1) {
        alert(parent);
    }
}