refactor(schema-utils): Remove unused Url helper (#24694)

This commit is contained in:
Sergei Zharinov 2023-09-28 14:33:26 +03:00 committed by GitHub
parent 5befa30dd6
commit d708f9a397
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 28 deletions

View file

@ -6,7 +6,6 @@ import {
LooseArray, LooseArray,
LooseRecord, LooseRecord,
Toml, Toml,
Url,
UtcDate, UtcDate,
Yaml, Yaml,
} from './schema-utils'; } from './schema-utils';
@ -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', () => { describe('Yaml', () => {
const Schema = Yaml.pipe( const Schema = Yaml.pipe(
z.object({ foo: z.array(z.object({ bar: z.literal('baz') })) }) z.object({ foo: z.array(z.object({ bar: z.literal('baz') })) })

View file

@ -226,15 +226,6 @@ export const UtcDate = z
return date; 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 => { export const Yaml = z.string().transform((str, ctx): JsonValue => {
try { try {
return load(str, { json: true }) as JsonValue; return load(str, { json: true }) as JsonValue;