@cloudinary-util/util
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -34,3 +34,4 @@ "use strict"; | ||
var REGEX_VERSION = /\/v\d+\//; | ||
var REGEX_URL = /https?:\/\/(?<host>[^\/]+)\/(?<cloudName>[^\/]+)\/(?<assetType>image|images|video|videos|raw|files)\/(?<deliveryType>upload|fetch|private|authenticated|sprite|facebook|twitter|youtube|vimeo)?\/?(?<signature>s\-\-[a-zA-Z0-9]+\-\-)?\/?(?<transformations>(?:[^_\/]+_[^,\/]+,?\/?)*\/)*(?<version>v\d+|\w{1,2})\/(?<publicId>[^\.^\s]+)(?<format>\.[a-zA-Z0-9]+$)?$/; | ||
var REGEX_FORMAT = /\.(ai|avif|gif|png|webp|bmp|bw|djvu|dng|ps|ept|eps|eps3|fbx|flif|gif|glb|gltf|heif|heic|ico|indd|jpg|jpe|jpeg|jp2|wdp|jxr|hdp|obj|pdf|ply|png|psd|arw|cr2|svg|tga|tif|tiff|u3ma|usdz|webp|3g2|3gp|avi|flv|m3u8|ts|m2ts|mts|mov|mkv|mp4|mpeg|mpd|mxf|ogv|webm|wmv)$/i; | ||
var REGEX_URL = /https?:\/\/(?<host>[^\/]+)\/(?<cloudName>[^\/]+)\/(?<assetType>image|images|video|videos|raw|files)\/(?<deliveryType>upload|fetch|private|authenticated|sprite|facebook|twitter|youtube|vimeo)?\/?(?<signature>s\-\-[a-zA-Z0-9]+\-\-)?\/?(?<transformations>(?:[^_\/]+_[^,\/]+,?\/?)*\/)*(?<version>v\d+|\w{1,2})\/(?<publicId>[^\s]+)$/; | ||
var ASSET_TYPES_SEO = ["images", "videos", "files"]; | ||
@@ -46,3 +47,10 @@ function parseUrl(src) { | ||
} | ||
const [baseUrl, queryString] = src.split("?"); | ||
const [baseUrlWithExtension, queryString] = src.split("?"); | ||
const formatMatches = baseUrlWithExtension.match(REGEX_FORMAT); | ||
let baseUrl = baseUrlWithExtension; | ||
let format; | ||
if (formatMatches !== null) { | ||
format = `${formatMatches[0]}`; | ||
baseUrl = baseUrlWithExtension.replace(new RegExp(`${format}$`), ""); | ||
} | ||
const results = baseUrl.match(REGEX_URL); | ||
@@ -52,2 +60,3 @@ const transformations = (_b = (_a = results == null ? void 0 : results.groups) == null ? void 0 : _a.transformations) == null ? void 0 : _b.split("/").filter((t) => !!t); | ||
...results == null ? void 0 : results.groups, | ||
format, | ||
seoSuffix: void 0, | ||
@@ -54,0 +63,0 @@ transformations: transformations || [], |
@@ -34,3 +34,4 @@ "use strict"; | ||
var REGEX_VERSION = /\/v\d+\//; | ||
var REGEX_URL = /https?:\/\/(?<host>[^\/]+)\/(?<cloudName>[^\/]+)\/(?<assetType>image|images|video|videos|raw|files)\/(?<deliveryType>upload|fetch|private|authenticated|sprite|facebook|twitter|youtube|vimeo)?\/?(?<signature>s\-\-[a-zA-Z0-9]+\-\-)?\/?(?<transformations>(?:[^_\/]+_[^,\/]+,?\/?)*\/)*(?<version>v\d+|\w{1,2})\/(?<publicId>[^\.^\s]+)(?<format>\.[a-zA-Z0-9]+$)?$/; | ||
var REGEX_FORMAT = /\.(ai|avif|gif|png|webp|bmp|bw|djvu|dng|ps|ept|eps|eps3|fbx|flif|gif|glb|gltf|heif|heic|ico|indd|jpg|jpe|jpeg|jp2|wdp|jxr|hdp|obj|pdf|ply|png|psd|arw|cr2|svg|tga|tif|tiff|u3ma|usdz|webp|3g2|3gp|avi|flv|m3u8|ts|m2ts|mts|mov|mkv|mp4|mpeg|mpd|mxf|ogv|webm|wmv)$/i; | ||
var REGEX_URL = /https?:\/\/(?<host>[^\/]+)\/(?<cloudName>[^\/]+)\/(?<assetType>image|images|video|videos|raw|files)\/(?<deliveryType>upload|fetch|private|authenticated|sprite|facebook|twitter|youtube|vimeo)?\/?(?<signature>s\-\-[a-zA-Z0-9]+\-\-)?\/?(?<transformations>(?:[^_\/]+_[^,\/]+,?\/?)*\/)*(?<version>v\d+|\w{1,2})\/(?<publicId>[^\s]+)$/; | ||
var ASSET_TYPES_SEO = ["images", "videos", "files"]; | ||
@@ -46,3 +47,10 @@ function parseUrl(src) { | ||
} | ||
const [baseUrl, queryString] = src.split("?"); | ||
const [baseUrlWithExtension, queryString] = src.split("?"); | ||
const formatMatches = baseUrlWithExtension.match(REGEX_FORMAT); | ||
let baseUrl = baseUrlWithExtension; | ||
let format; | ||
if (formatMatches !== null) { | ||
format = `${formatMatches[0]}`; | ||
baseUrl = baseUrlWithExtension.replace(new RegExp(`${format}$`), ""); | ||
} | ||
const results = baseUrl.match(REGEX_URL); | ||
@@ -52,2 +60,3 @@ const transformations = (_b = (_a = results == null ? void 0 : results.groups) == null ? void 0 : _a.transformations) == null ? void 0 : _b.split("/").filter((t) => !!t); | ||
...results == null ? void 0 : results.groups, | ||
format, | ||
seoSuffix: void 0, | ||
@@ -54,0 +63,0 @@ transformations: transformations || [], |
{ | ||
"name": "@cloudinary-util/util", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.mjs", |
Sorry, the diff of this file is not supported yet
18472
419