Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 862a78d

Browse files
committed
refactor(ngMocks): ignore query/hash when extracting path params for MockHttpExpectation
1 parent bd772ab commit 862a78d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ngMock/angular-mocks.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,9 @@ function assertArgDefined(args, index, name) {
20922092
}
20932093
}
20942094

2095+
function stripQueryAndHash(url) {
2096+
return url.replace(/[?#].*$/, '');
2097+
}
20952098

20962099
function MockHttpExpectation(method, url, data, headers, keys) {
20972100

@@ -2146,15 +2149,17 @@ function MockHttpExpectation(method, url, data, headers, keys) {
21462149

21472150
this.params = function(u) {
21482151
var queryStr = u.indexOf('?') === -1 ? '' : u.substring(u.indexOf('?') + 1);
2152+
var strippedUrl = stripQueryAndHash(u);
21492153

2150-
return angular.extend(parseQuery(queryStr), pathParams());
2154+
return angular.extend(parseQuery(queryStr), pathParams(strippedUrl));
21512155

2152-
function pathParams() {
2156+
function pathParams(strippedUrl) {
21532157
var keyObj = {};
21542158
if (!url || !angular.isFunction(url.test) || !keys || keys.length === 0) return keyObj;
21552159

2156-
var m = url.exec(u);
2160+
var m = url.exec(strippedUrl);
21572161
if (!m) return keyObj;
2162+
21582163
for (var i = 1, len = m.length; i < len; ++i) {
21592164
var key = keys[i - 1];
21602165
var val = m[i];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy