mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-03 11:03:39 +00:00
930cf6633c
fix: Additional vi.mock path corrections and prettier formatting
29 lines
738 B
TypeScript
29 lines
738 B
TypeScript
import type { UrlParsedResult } from '../types.ts';
|
|
import type { HomebrewUrlHandler } from './base.ts';
|
|
import { GitHubUrlHandler } from './github.ts';
|
|
import { NpmUrlHandler } from './npm.ts';
|
|
|
|
const handlers: HomebrewUrlHandler[] = [
|
|
new GitHubUrlHandler(),
|
|
new NpmUrlHandler(),
|
|
];
|
|
|
|
export function findHandler(
|
|
url: string | null,
|
|
): { handler: HomebrewUrlHandler; parsed: UrlParsedResult } | null {
|
|
if (!url) {
|
|
return null;
|
|
}
|
|
for (const handler of handlers) {
|
|
const parsed = handler.parseUrl(url);
|
|
if (parsed) {
|
|
return { handler, parsed };
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function findHandlerByType(type: string): HomebrewUrlHandler | null {
|
|
return handlers.find((h) => h.type === type) ?? null;
|
|
}
|