@cloudinary-util/util
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -25,2 +25,3 @@ "use strict"; | ||
encodeBase64: () => encodeBase64, | ||
getFormat: () => getFormat, | ||
getPublicId: () => getPublicId, | ||
@@ -50,7 +51,5 @@ getTransformations: () => getTransformations, | ||
const [baseUrlWithExtension, queryString] = src.split("?"); | ||
const formatMatches = baseUrlWithExtension.match(REGEX_FORMAT); | ||
const format = getFormat(baseUrlWithExtension); | ||
let baseUrl = baseUrlWithExtension; | ||
let format; | ||
if (formatMatches !== null) { | ||
format = `${formatMatches[0]}`; | ||
if (format) { | ||
baseUrl = baseUrlWithExtension.replace(new RegExp(`${format}$`), ""); | ||
@@ -93,2 +92,8 @@ } | ||
} | ||
function getFormat(src) { | ||
const matches = src.match(REGEX_FORMAT); | ||
if (matches === null) | ||
return; | ||
return matches[0]; | ||
} | ||
@@ -148,2 +153,3 @@ // src/lib/colors.ts | ||
encodeBase64, | ||
getFormat, | ||
getPublicId, | ||
@@ -150,0 +156,0 @@ getTransformations, |
@@ -21,5 +21,5 @@ /** | ||
* getPublicId | ||
* @description Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self. | ||
* @description Retrieves the public id of a Cloudinary image url. If no url is recognized it returns the parameter it self. | ||
* If it's recognized that is a url and it's not possible to get the public id, it warns the user. | ||
* @param {string} src: The cloudiary url or public id. | ||
* @param {string} src: The Cloudinary url or public id. | ||
*/ | ||
@@ -30,5 +30,11 @@ declare function getPublicId(src: string): string | undefined; | ||
* @description Retrieves the transformations added to a Cloudinary image url. If no transformation is recognized it returns an empty array. | ||
* @param {string} src: The cloudiary url | ||
* @param {string} src: The Cloudinary url | ||
*/ | ||
declare function getTransformations(src: string): string[][]; | ||
/** | ||
* getFormat | ||
* @description Retrieves the format of a given string | ||
* @param {string} src: The Cloudinary url or any string trying to match the format | ||
*/ | ||
declare function getFormat(src: string): string | undefined; | ||
@@ -63,2 +69,2 @@ /** | ||
export { ParseUrl, convertColorHexToRgb, encodeBase64, getPublicId, getTransformations, objectHasKey, parseUrl, sortByKey, testColorIsHex }; | ||
export { ParseUrl, convertColorHexToRgb, encodeBase64, getFormat, getPublicId, getTransformations, objectHasKey, parseUrl, sortByKey, testColorIsHex }; |
@@ -25,2 +25,3 @@ "use strict"; | ||
encodeBase64: () => encodeBase64, | ||
getFormat: () => getFormat, | ||
getPublicId: () => getPublicId, | ||
@@ -50,7 +51,5 @@ getTransformations: () => getTransformations, | ||
const [baseUrlWithExtension, queryString] = src.split("?"); | ||
const formatMatches = baseUrlWithExtension.match(REGEX_FORMAT); | ||
const format = getFormat(baseUrlWithExtension); | ||
let baseUrl = baseUrlWithExtension; | ||
let format; | ||
if (formatMatches !== null) { | ||
format = `${formatMatches[0]}`; | ||
if (format) { | ||
baseUrl = baseUrlWithExtension.replace(new RegExp(`${format}$`), ""); | ||
@@ -93,2 +92,8 @@ } | ||
} | ||
function getFormat(src) { | ||
const matches = src.match(REGEX_FORMAT); | ||
if (matches === null) | ||
return; | ||
return matches[0]; | ||
} | ||
@@ -148,2 +153,3 @@ // src/lib/colors.ts | ||
encodeBase64, | ||
getFormat, | ||
getPublicId, | ||
@@ -150,0 +156,0 @@ getTransformations, |
{ | ||
"name": "@cloudinary-util/util", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.mjs", |
Sorry, the diff of this file is not supported yet
20469
496