Skip to content

Commit daf1ea5

Browse files
Allow empty string as valid URL in DCR workflow
1 parent 856d9ec commit daf1ea5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/shared/auth.test.ts

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

2424
it('rejects invalid URLs', () => {
2525
expect(() => SafeUrlSchema.parse('not-a-url')).toThrow();
26-
expect(() => SafeUrlSchema.parse('')).toThrow();
2726
});
2827

2928
it('works with safeParse', () => {
3029
expect(() => SafeUrlSchema.safeParse('not-a-url')).not.toThrow();
3130
});
31+
32+
it('works with empty string', () => {
33+
expect(() => SafeUrlSchema.parse('')).not.toThrow();
34+
});
3235
});
3336

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

src/shared/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const SafeUrlSchema = z.string().url()
2020
return u.protocol !== 'javascript:' && u.protocol !== 'data:' && u.protocol !== 'vbscript:';
2121
},
2222
{ message: "URL cannot use javascript:, data:, or vbscript: scheme" }
23-
);
23+
).or(z.literal(""));
2424

2525

2626
/**

0 commit comments

Comments
 (0)