Searching for URL's Relative to Site Root in Javascript Source
        Posted  
        
            by James
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by James
        
        
        
        Published on 2010-04-20T14:39:44Z
        Indexed on 
            2010/04/20
            15:13 UTC
        
        
        Read the original article
        Hit count: 204
        
Hi,
I am working on a web site with several other developers and we have had problems where people commit JavaScript code with AJAX calls that use URL's relative to the site root. An example would be /Home/Index which will not work if the site is hosted in a virtual directory.
To get round the problem we use a $.url() method to convert it to a full path, e.g.
$("#container").load($.url("/Home/Index"))
I am trying to write a unit test that will search each JavaScript file and find places where the $.url method is not being used. The only problem is that I cannot seem to write a regex expression to do this. I have tried the following:
(?!\$\.url\()"(/\w*)+"
But this does not work. I cannot find a way to say that I don't want the $.url in front. Does anyone know if this is possible? Note that I need regular expressions that are compatible with .NET
Thanks.
© Stack Overflow or respective owner