0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-13 08:01:49 +00:00
renovatebot_renovate/lib/modules/versioning/pvp/range.ts
renovate[bot] 55845508b6
chore(deps): update eslint monorepo to v9 (major) (#33573)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-02-20 11:31:13 +00:00

21 lines
620 B
TypeScript

import { regEx } from '../../../util/regex';
import type { Range } from './types';
// This range format was chosen because it is common in the ecosystem
const gteAndLtRange = regEx(/>=(?<lower>[\d.]+)&&<(?<upper>[\d.]+)/);
const ltAndGteRange = regEx(/<(?<upper>[\d.]+)&&>=(?<lower>[\d.]+)/);
export function parseRange(input: string): Range | null {
const noSpaces = input.replaceAll(' ', '');
let m = gteAndLtRange.exec(noSpaces);
if (!m?.groups) {
m = ltAndGteRange.exec(noSpaces);
if (!m?.groups) {
return null;
}
}
return {
lower: m.groups.lower,
upper: m.groups.upper,
};
}