fix(ci): redact authentication in case-insensitive URL schemes

This commit is contained in:
gensokyo-dev committed 2026-10-23 13:38:56 +00:00
1 parent 1cd471487b
commit 95eb175457
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
/** Redact only HTTP URL authentication; keep paths, names, queries and other text. */
export function redactTransportAuthentication(text) {
return text.replace(/https?:\/\/[^\s"<>\\]+/gu, (value) => {
return text.replace(/https?:\/\/[^\s"<>\\]+/giu, (value) => {
try {
const parsed = new URL(value);
if (!parsed.username && !parsed.password) return value;
@@ -115,6 +115,13 @@ it("accepts only supported registry identities and redacts only transport authen
expect(redactTransportAuthentication(text)).toBe(
"name=secret token=caller-value /tmp/secret https://EXAMPLE.com/a?q=token#keep",
);
for (const scheme of ["HTTPS", "hTtPs", "HTTP"]) {
expect(
redactTransportAuthentication(
`${scheme}://user:fixture-secret@EXAMPLE.com/a?q=token#keep`,
),
).toBe(`${scheme}://EXAMPLE.com/a?q=token#keep`);
}
expect(() =>
lockedPackages({
lockfileVersion: 3,