Javascript regex URL matching

Posted by Blondie on Stack Overflow See other posts from Stack Overflow or by Blondie
Published on 2010-05-15T00:23:04Z Indexed on 2010/05/15 0:34 UTC
Read the original article Hit count: 667

I have this so far:

chrome.tabs.getSelected(null, function(tab) 
{
    var title = tab.title;
    var btn = '<a href="' + tab.url + '" onclick="save(\'' + title + '\');"> ' + title + '</a>';

    if(tab.url.match('/http:\/\/www.mydomain.com\/version.php/i')) 
    {
        document.getElementById('link').innerHTML = '<p>' + btn + '</p>';
    }
});

Basically it should match the domain within this:

http://www.mydomain.com/version.php?*

Anything that matches that even when it includes something like version.php?ver=1, etc

When I used the code above of mine, it doesn't display anything, but when I remove the if statement, it's fine but it shows on other pages which it shouldn't only on the matched URL.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex