| 1 | import { assert, it } from "@effect/vitest" |
| 2 | import { FindMyWay as Router } from "effect/http" |
| 3 | |
| 4 | it("should sanitize the url - query", () => { |
| 5 | const router = Router.make<boolean>() |
| 6 | router.on("GET", "/test", true) |
| 7 | assert.deepStrictEqual( |
| 8 | router.find("GET", "/test?hello=world")?.searchParams, |
| 9 | { hello: "world" } |
| 10 | ) |
| 11 | }) |
| 12 | |
| 13 | it("should sanitize the url - hash", () => { |
| 14 | const router = Router.make<boolean>() |
| 15 | |
| 16 | router.on("GET", "/test", true) |
| 17 | |
| 18 | assert.deepStrictEqual(router.find("GET", "/test#hello")?.searchParams, { |
| 19 | hello: "" |
| 20 | }) |
| 21 | }) |
| 22 | |
| 23 | it("handles path and query separated by ;", () => { |
| 24 | const router = Router.make<boolean>() |
| 25 | router.on("GET", "/test", true) |
| 26 | assert.deepStrictEqual( |
| 27 | router.find("GET", "/test;jsessionid=123456")?.searchParams, |
| 28 | { jsessionid: "123456" } |
| 29 | ) |
| 30 | }) |
| 31 | |
| 32 | it("handles %", () => { |
| 33 | const router = Router.make<boolean>() |
| 34 | router.on("GET", "/test", true) |
| 35 | assert.deepStrictEqual(router.find("GET", "/test?%")?.searchParams, { |
| 36 | "%": "" |
| 37 | }) |
| 38 | }) |