title: How to use regex in AngularJS $httpBackend ExpectGET
body: <p>I'm passing a url as a parameter in a $resource GET request.  Angular is url encoding this parameter and matching the request in the $httpBackend.expectGET method is finicky.  </p>
  
  <p>I see that you can use regular expressions to match the expected request but can't get it to work.  I'd like to match the resource location but with any "uri" query string parameter value.</p>
  
  <p><strong>Ctrl</strong></p>
  
  <pre><code>var resource = $resource('../api/lookup');
  resource.get({ uri: "http://www.something.com" }, function (data) {
    // do something
  });
  </code></pre>
  
  <p><strong>Test</strong></p>
  
  <pre><code>// mock out the $httpBackend response
  
  $httpBackend.expectGET(/\.\.\/api\/lookup\?uri=.*/)).respond(200, { Response: "a response" });
  
  // call my test method here
  
  // ensure the $httpBackend work is done
  $rootScope.$apply();
  $httpBackend.flush();
  
  // do assertions
  </code></pre>
  
  <p><strong>Karma Output</strong></p>
  
  <pre><code>Error: Unexpected request: GET ../api/lookup?uri=http%3A%2F%2Fwww.something.com
  
  Expected GET /../api/lookup?uri=.*/
  </code></pre>
  
  <p>Can anyone see why my regex isn't being matched?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Even after improving the regex as suggested I couldn't get this working using the '<em>$var</em>' injection syntax.  I rewrote the tests, injecting the dependencies with the inject function and ensuring the order of my test arrangement was correct.  Now it's working like a charm!</p>