@beyonk/content-delivery
Advanced tools
Comparing version 5.3.0 to 5.3.1
import { extension, getDeliveryType, types } from './mime-type.js' | ||
function buildUrl (cdnBaseUrl, environmentName, width, paths, deliveryType, extension = 'jpeg') { | ||
const base = [ cdnBaseUrl ] | ||
const { pathname: existingPath } = new URL(cdnBaseUrl) | ||
const base = [ | ||
existingPath, | ||
deliveryType, | ||
'beyonk', | ||
environmentName === 'prod' ? 'p' : 'q', | ||
...deliveryType === types.image ? [ width ] : [], | ||
...paths | ||
] | ||
base.push(deliveryType) | ||
base.push('beyonk') | ||
base.push(environmentName === 'prod' ? 'p' : 'q') | ||
if (deliveryType === types.image) { | ||
base.push(width) | ||
} | ||
base.push(...paths) | ||
return `${base.join('/')}.${extension}` | ||
const path = `${base.join('/')}.${extension}` | ||
return new URL(path, cdnBaseUrl).toString() | ||
} | ||
@@ -36,7 +37,8 @@ | ||
return [ | ||
`https://${cdnId}.beyonk.com`, | ||
const base = [ | ||
metadata.path, | ||
`${metadata.id}.${extension(metadata.type)}` | ||
].join('/') | ||
] | ||
return new URL(base.join('/'), `https://${cdnId}.beyonk.com`).toString() | ||
} | ||
@@ -43,0 +45,0 @@ |
function generateSocialImageUrl (cdnBaseUrl, environmentName, type, id, isPortal = false) { | ||
const base = [ cdnBaseUrl, 's', 'beyonk' ] | ||
const env = environmentName === 'prod' ? 'p' : 'q' | ||
const { pathname: existingPath } = new URL(cdnBaseUrl) | ||
const base = [ | ||
existingPath, | ||
's', | ||
'beyonk', | ||
environmentName === 'prod' ? 'p' : 'q', | ||
type, | ||
id | ||
] | ||
base.push(env) | ||
base.push(type) | ||
base.push(id) | ||
const url = new URL(base.join('/'), cdnBaseUrl) | ||
if (isPortal) { | ||
base.push('?portal=true') | ||
url.searchParams.append('portal', 'true') | ||
} | ||
const url = base.join('/') | ||
return url | ||
return url.toString() | ||
} | ||
@@ -17,0 +20,0 @@ |
{ | ||
"name": "@beyonk/content-delivery", | ||
"version": "5.3.0", | ||
"version": "5.3.1", | ||
"description": "Beyonk Content Delivery Utils", | ||
@@ -5,0 +5,0 @@ "author": "Antony Jones <aj@desirableobjects.co.uk>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19909
524