feat(cdn): derive Ubuntu slot from codename
This commit is contained in:
parent
a8820e6e90
commit
83393491ef
1 changed files with 16 additions and 0 deletions
|
|
@ -58,6 +58,7 @@ const MACOS_BIN_REGEX =
|
|||
const RHEL_REGEX = /(almalinux|rocky)[^\d]*(\d+)/i;
|
||||
|
||||
const UBUNTU_REGEX = /Ubuntu ([\d.]+)/i;
|
||||
const UBUNTU_CODENAME_REGEX = /Ubuntu [\d.]+;\s*codename=([a-z][a-z0-9-]*)/i;
|
||||
const UBUNTU_CODENAMES: Record<string, string> = {
|
||||
'26.04': 'resolute',
|
||||
'24.04': 'noble',
|
||||
|
|
@ -137,6 +138,11 @@ function parseSlot(userAgent: string): string | null {
|
|||
|
||||
const ubuntu = userAgent.match(UBUNTU_REGEX);
|
||||
if (ubuntu) {
|
||||
const codenameMatch = userAgent.match(UBUNTU_CODENAME_REGEX);
|
||||
if (codenameMatch) {
|
||||
return `${arch}/${codenameMatch[1].toLowerCase()}`;
|
||||
}
|
||||
|
||||
const codename = UBUNTU_CODENAMES[ubuntu[1]];
|
||||
if (codename) {
|
||||
return `${arch}/${codename}`;
|
||||
|
|
|
|||
Loading…
Reference in a new issue