mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
refactor(schema-utils): Remove unused Url
helper (#24694)
This commit is contained in:
parent
5befa30dd6
commit
d708f9a397
2 changed files with 0 additions and 28 deletions
|
@ -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') })) })
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue