Skip to content

Commit 8122c17

Browse files
Allow empty string as valid URL in DCR workflow
1 parent e0de082 commit 8122c17

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/shared/auth.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ describe('SafeUrlSchema', () => {
1818

1919
it('rejects invalid URLs', () => {
2020
expect(() => SafeUrlSchema.parse('not-a-url')).toThrow();
21-
expect(() => SafeUrlSchema.parse('')).toThrow();
2221
});
2322

2423
it('works with safeParse', () => {
2524
expect(() => SafeUrlSchema.safeParse('not-a-url')).not.toThrow();
2625
});
26+
27+
it('works with empty string', () => {
28+
expect(() => SafeUrlSchema.parse('')).not.toThrow();
29+
});
2730
});
2831

2932
describe('OAuthMetadataSchema', () => {

src/shared/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export const SafeUrlSchema = z
2323
return u.protocol !== 'javascript:' && u.protocol !== 'data:' && u.protocol !== 'vbscript:';
2424
},
2525
{ message: 'URL cannot use javascript:, data:, or vbscript: scheme' }
26-
);
26+
)
27+
.or(z.literal(''));
2728

2829
/**
2930
* RFC 9728 OAuth Protected Resource Metadata

0 commit comments

Comments
 (0)