mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-02 11:01:36 +02:00
5004c395de
Co-authored-by: Simon Johansson <simon.johansson@infor.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Gregory Schier <gschier1990@gmail.com>
29 lines
1018 B
TypeScript
29 lines
1018 B
TypeScript
import { describe, expect, test } from "vite-plus/test";
|
|
import { extractPathPlaceholders } from "./pathPlaceholders";
|
|
|
|
describe("extractPathPlaceholders", () => {
|
|
test("extracts a single placeholder", () => {
|
|
expect(extractPathPlaceholders("/users/:id")).toEqual([":id"]);
|
|
});
|
|
|
|
test("extracts multiple placeholders", () => {
|
|
expect(extractPathPlaceholders("/users/:id/posts/:postId")).toEqual([":id", ":postId"]);
|
|
});
|
|
|
|
test("stops at a literal `:` in the same segment", () => {
|
|
expect(extractPathPlaceholders("/tasks/:id:cancel")).toEqual([":id"]);
|
|
});
|
|
|
|
test("does not match `:foo` mid-segment", () => {
|
|
expect(extractPathPlaceholders("/users/abc:def")).toEqual([]);
|
|
});
|
|
|
|
test("does not match `:` in a host port", () => {
|
|
expect(extractPathPlaceholders("https://example.com:8080/users/:id")).toEqual([":id"]);
|
|
});
|
|
|
|
test("returns empty for a URL with no placeholders", () => {
|
|
expect(extractPathPlaceholders("https://example.com/foo/bar?q=1#hash")).toEqual([]);
|
|
});
|
|
});
|