70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import { describe, test } from "vitest";
|
|
import { stripLeadingDoubleSlashes } from "../../asset-server/responses";
|
|
|
|
describe("stripLeadingDoubleSlashes", () => {
|
|
test("strips extra leading `/`, `%2F`, `%2f`s, spaces, and tabs", ({
|
|
expect,
|
|
}) => {
|
|
expect(stripLeadingDoubleSlashes("/")).toMatchInlineSnapshot(`"/"`);
|
|
expect(stripLeadingDoubleSlashes("/%2Ffoo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%2ffoo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%2F%2f/foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%5Cfoo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%5cfoo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%5C%5c/foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%2f%5c/foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/\\/foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("%2ffoo")).toMatchInlineSnapshot(`"/foo"`);
|
|
expect(stripLeadingDoubleSlashes("/foo/%2f")).toMatchInlineSnapshot(
|
|
`"/foo/%2f"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/foo/%2F")).toMatchInlineSnapshot(
|
|
`"/foo/%2F"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/foo//")).toMatchInlineSnapshot(
|
|
`"/foo//"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/foo//bar")).toMatchInlineSnapshot(
|
|
`"/foo//bar"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/foo/\\/bar")).toMatchInlineSnapshot(
|
|
`"/foo/\\/bar"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%09foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
expect(stripLeadingDoubleSlashes("/%09/foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
// Unencoded space / tab
|
|
expect(
|
|
stripLeadingDoubleSlashes("/%09/foo/%09/ / /")
|
|
).toMatchInlineSnapshot(`"/foo/%09/ / /"`);
|
|
// Unencoded space
|
|
expect(stripLeadingDoubleSlashes("/ /foo")).toMatchInlineSnapshot(`"/foo"`);
|
|
// Unencoded tab
|
|
expect(stripLeadingDoubleSlashes("/ /foo")).toMatchInlineSnapshot(
|
|
`"/foo"`
|
|
);
|
|
});
|
|
});
|