Skip to content

Commit f180099

Browse files
committed
add whitelist to treat '%' as regular character
1 parent 863fb71 commit f180099

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/createMockMiddleware.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default function getMockMiddleware(mockDir, options) {
7070
method = splited[0].toLowerCase();
7171
path = splited[1]; // eslint-disable-line
7272
}
73+
// debug(`parsed: ${method} ${path}`);
7374
assert(
7475
VALID_METHODS.includes(method),
7576
`Invalid method ${method} for path ${path}, please check your mock files.`
@@ -114,7 +115,11 @@ export default function getMockMiddleware(mockDir, options) {
114115
);
115116
const { method, path } = parseKey(key);
116117
const keys = [];
117-
const re = pathToRegexp(path, keys);
118+
const pathOptions = {
119+
whitelist: ['%'], // treat %3A as regular chars
120+
};
121+
const re = pathToRegexp(path, keys, pathOptions);
122+
// debug(re);
118123
memo.push({
119124
method,
120125
path,

0 commit comments

Comments
 (0)