Skip to content

Function: parseCdnUrl() ​

ts
function parseCdnUrl(url): ParsedCdnUrl;

Defined in: parse.ts:275

Parses any Uploadcare CDN URL — file, group, group element, conversion result or proxified remote source — into a ParsedCdnUrl discriminated by kind.

Parsing is lenient about operations: unknown directives (including internal @-prefixed ones) are preserved verbatim, so serializeCdnUrl(parseCdnUrl(url)) === url.

Parameters ​

ParameterType
urlstring

Returns ​

ParsedCdnUrl

Throws ​

TypeError when the URL cannot be interpreted as a CDN URL.

See ​

https://uploadcare.com/docs/cdn-operations/

Example ​

ts
parseCdnUrl(`https://ucarecdn.com/${uuid}/-/resize/300x/photo.jpg`)
// → { kind: 'file', uuid, operations: [{ name: 'resize', params: ['300x'] }], filename: 'photo.jpg', ... }