Skip to content

Commit

Permalink
refactor(schema-utils): Remove unused Url helper (#24694)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Sep 28, 2023
1 parent 5befa30 commit d708f9a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
19 changes: 0 additions & 19 deletions lib/util/schema-utils.spec.ts
Expand Up @@ -6,7 +6,6 @@ import {
LooseArray,
LooseRecord,
Toml,
Url,
UtcDate,
Yaml,
} from './schema-utils';
Expand Down Expand Up @@ -281,24 +280,6 @@ describe('util/schema-utils', () => {
});
});

describe('Url', () => {
it('parses valid URLs', () => {
const urlStr = 'https://www.example.com/foo/bar?baz=qux';
const parsedUrl = Url.parse(urlStr);
expect(parsedUrl).toMatchObject({
protocol: 'https:',
hostname: 'www.example.com',
pathname: '/foo/bar',
search: '?baz=qux',
});
});

it('throws an error for invalid URLs', () => {
const urlStr = 'invalid-url-string';
expect(() => Url.parse(urlStr)).toThrow('Invalid URL');
});
});

describe('Yaml', () => {
const Schema = Yaml.pipe(
z.object({ foo: z.array(z.object({ bar: z.literal('baz') })) })
Expand Down
9 changes: 0 additions & 9 deletions lib/util/schema-utils.ts
Expand Up @@ -226,15 +226,6 @@ export const UtcDate = z
return date;
});

export const Url = z.string().transform((str, ctx): URL => {
try {
return new URL(str);
} catch (e) {
ctx.addIssue({ code: 'custom', message: 'Invalid URL' });
return z.NEVER;
}
});

export const Yaml = z.string().transform((str, ctx): JsonValue => {
try {
return load(str, { json: true }) as JsonValue;
Expand Down

0 comments on commit d708f9a

Please sign in to comment.