mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 13:38:32 +00:00
23 lines
711 B
TypeScript
23 lines
711 B
TypeScript
import { coerceArray } from '../../../util/array';
|
|
import { filterMap } from '../../../util/filter-map';
|
|
import { compare } from '../../versioning/maven/compare';
|
|
|
|
const linkRegExp = /(?<=href=['"])[^'"]*(?=\/['"])/gi;
|
|
|
|
export function extractPageLinks(
|
|
html: string,
|
|
filterMapHref: (href: string) => string | null | undefined,
|
|
): string[] {
|
|
const unfiltered = coerceArray(html.match(linkRegExp));
|
|
return filterMap(unfiltered, filterMapHref);
|
|
}
|
|
|
|
export function getLatestVersion(versions: string[] | null): string | null {
|
|
if (versions?.length) {
|
|
return versions.reduce((latestVersion, version) =>
|
|
compare(version, latestVersion) === 1 ? version : latestVersion,
|
|
);
|
|
}
|
|
return null;
|
|
}
|