fix: correct the error message about the path not being a string in the router pass-through function

This commit is contained in:
Dorian Niemiec 2025-01-01 21:33:59 +01:00
parent 61e09642e5
commit c0c69246d2
2 changed files with 2 additions and 2 deletions

View file

@ -70,7 +70,7 @@ function svrouter() {
if (typeof realCallback !== "function") {
throw new Error("The passed callback must be a function.");
} else if (callback && typeof path !== "string") {
throw new Error("The path must be a function");
throw new Error("The path must be a string.");
}
const realPath = callback ? path.replace(/\/+$/, "") : "";

View file

@ -216,7 +216,7 @@ describe("SVRouter", () => {
test("should throw an error if path is not a string in passRoute", () => {
expect(() => {
router.pass(123, () => {});
}).toThrow("The path must be a function");
}).toThrow("The path must be a string.");
});
test("should handle errors thrown in route callbacks gracefully", () => {