Skip to content

Commit f10359a

Browse files
committed
fix: stripping end slash
1 parent 06660a6 commit f10359a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

build/core/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ exports.handleMockEndpoint = void 0;
1616
const mockProcessor_1 = __importDefault(require("./mockProcessor"));
1717
const mockSelector_1 = __importDefault(require("./mockSelector"));
1818
const handleMockEndpoint = (req) => __awaiter(void 0, void 0, void 0, function* () {
19-
const endpoint = req.path.slice(1);
19+
// Stripping front slash. Eg: /users/123/ -> users/123/
20+
let endpoint = req.path.slice(1);
21+
// Stripping end slash. Eg: users/123/ -> users/123
22+
if (endpoint.slice(-1) === "/") {
23+
endpoint = endpoint.slice(0, -1);
24+
}
2025
const method = req.method;
2126
const queryParams = req.query || {};
2227
const kwargs = {

src/core/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import MockProcessor from "./mockProcessor";
33
import MockSelector from "./mockSelector";
44

55
export const handleMockEndpoint = async (req: any): Promise<MockServerResponse> => {
6-
const endpoint = req.path.slice(1);
6+
// Stripping front slash. Eg: /users/123/ -> users/123/
7+
let endpoint = req.path.slice(1);
8+
9+
// Stripping end slash. Eg: users/123/ -> users/123
10+
if(endpoint.slice(-1) === "/") {
11+
endpoint = endpoint.slice(0, -1);
12+
}
13+
714
const method = req.method as RequestMethod;
815
const queryParams = req.query || {};
916

0 commit comments

Comments
 (0)