mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-05 05:28:37 +01:00
Type a loose address (media.example.com, https://…, host:port) and the app finds the working, canonical URL. - utils/serverUrl: generic candidate generator (https-first, port/path preserved, no Jellyfin-specific ports), parallel-probe resolver, numeric semver compare, and a Jellyseerr probe (/api/v1/status, min 2.0.0). - useServerUrlResolver: idle -> resolving -> ok | error state machine with cancellation. - ServerUrlField: shared input that auto-resolves on blur, inline status chip (tap to re-test) + resolved URL, persists the canonical URL. - Jellyseerr settings adopt the field and log in with the resolved URL. Probe contract makes Streamystats/Jellyfin/Merlin a drop-in follow-up.
23 lines
700 B
TypeScript
23 lines
700 B
TypeScript
/**
|
|
* Strict numeric "below" comparison for dotted versions.
|
|
*
|
|
* Avoids the string-comparison bug (`"1.9.9" < "2.0.0"` works by luck but
|
|
* `"2.10.0" < "2.0.0"` is wrongly true). Non-numeric/pre-release suffixes on a
|
|
* segment are ignored (e.g. `2.0.0-beta` → 2.0.0).
|
|
*/
|
|
export function isVersionBelow(version: string, minimum: string): boolean {
|
|
const parse = (v: string) =>
|
|
v.split(".").map((segment) => Number.parseInt(segment, 10) || 0);
|
|
|
|
const a = parse(version);
|
|
const b = parse(minimum);
|
|
const length = Math.max(a.length, b.length);
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
const x = a[i] ?? 0;
|
|
const y = b[i] ?? 0;
|
|
if (x !== y) return x < y;
|
|
}
|
|
return false;
|
|
}
|