Skip to content

Commit 995573a

Browse files
committed
fix(test): exclude punycode slugs from URL parser property tests
The orgSlugArb and projectSlugArb generators could produce strings starting with 'xn--' (punycode-encoded IDN labels). When used as a subdomain (e.g. 'xn--0a.sentry.io'), the URL constructor silently decodes the punycode, collapsing the hostname to 'sentry.io' and dropping the org. This caused flaky failures in the buildTraceUrl → parseSentryUrl round-trip test. Fix: filter out xn-- prefixed slugs since real Sentry org/project slugs are never punycode-encoded.
1 parent f7198cc commit 995573a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/lib/sentry-url-parser.property.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ import {
2020
} from "../../src/lib/sentry-urls.js";
2121
import { DEFAULT_NUM_RUNS } from "../model-based/helpers.js";
2222

23-
/** Generates valid org slugs (lowercase, alphanumeric with hyphens) */
24-
const orgSlugArb = stringMatching(/^[a-z][a-z0-9-]{1,20}[a-z0-9]$/);
23+
/**
24+
* Generates valid org slugs (lowercase, alphanumeric with hyphens).
25+
*
26+
* Excludes `xn--` prefixes (punycode-encoded IDN labels) because the URL
27+
* constructor silently decodes them, collapsing `xn--XX.sentry.io` into
28+
* `sentry.io` and dropping the org subdomain.
29+
*/
30+
const orgSlugArb = stringMatching(/^[a-z][a-z0-9-]{1,20}[a-z0-9]$/).filter(
31+
(s) => !s.startsWith("xn--")
32+
);
2533

2634
/** Generates valid project slugs (lowercase, alphanumeric with hyphens) */
27-
const projectSlugArb = stringMatching(/^[a-z][a-z0-9-]{1,20}[a-z0-9]$/);
35+
const projectSlugArb = stringMatching(/^[a-z][a-z0-9-]{1,20}[a-z0-9]$/).filter(
36+
(s) => !s.startsWith("xn--")
37+
);
2838

2939
/** Generates valid 32-character hex trace IDs */
3040
const traceIdArb = stringMatching(/^[0-9a-f]{32}$/);

0 commit comments

Comments
 (0)