@yeepay/client-utils 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,9 @@ function longestCommonPrefix(strs) {
|
|
|
16
16
|
}
|
|
17
17
|
return prefix;
|
|
18
18
|
}
|
|
19
|
+
function escapeRegExp(string) {
|
|
20
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21
|
+
}
|
|
19
22
|
function setupMockAdapter(axiosInstance, mockModules) {
|
|
20
23
|
if (!mockModules) return;
|
|
21
24
|
const mock = new AxiosMockAdapter(axiosInstance);
|
|
@@ -26,7 +29,7 @@ function setupMockAdapter(axiosInstance, mockModules) {
|
|
|
26
29
|
const dotIndex = path.lastIndexOf(".");
|
|
27
30
|
const uri = path.slice(longestPrefixIndex, dotIndex);
|
|
28
31
|
const registerMock = (mod) => {
|
|
29
|
-
mock.onAny(new RegExp(uri)).reply(200, mod);
|
|
32
|
+
mock.onAny(/* @__PURE__ */ new RegExp(`^${escapeRegExp(uri)}$`)).reply(200, mod);
|
|
30
33
|
};
|
|
31
34
|
if (typeof mockModules[path] === "function") mockModules[path]().then(registerMock).catch((error) => {
|
|
32
35
|
console.error(`@yeepay/client-utils mock trying to loading ${path} failed`, error);
|
package/package.json
CHANGED