@jlengstorf/get-share-image
Advanced tools
Comparing version 0.2.1 to 0.3.0
18
index.js
"use strict"; | ||
exports.__esModule = true; | ||
/** | ||
* Encodes characters for Cloudinary URL | ||
* Encodes some not allowed in Cloudinary parameter values twice: | ||
* hash, comma, slash, question mark, backslash | ||
* https://support.cloudinary.com/hc/en-us/articles/202521512-How-to-add-a-slash-character-or-any-other-special-characters-in-text-overlays- | ||
*/ | ||
function cleanText(text) { | ||
return encodeURIComponent(text).replace(/%(23|2C|2F|3F|5C)/g, "%25$1"); | ||
} | ||
; | ||
/** | ||
* Generates a social sharing image with custom text using Cloudinary’s APIs. | ||
@@ -26,6 +36,6 @@ * | ||
"y_" + titleBottomOffset, | ||
"l_text:" + titleFont + "_" + titleFontSize + titleExtraConfig + ":" + encodeURIComponent(title), | ||
"l_text:" + titleFont + "_" + titleFontSize + titleExtraConfig + ":" + cleanText(title), | ||
].join(','); | ||
// configure the tagline text | ||
var taglineConfig = [ | ||
var taglineConfig = tagline ? [ | ||
"w_" + textAreaWidth, | ||
@@ -37,4 +47,4 @@ 'c_fit', | ||
"y_" + taglineTopOffset, | ||
"l_text:" + taglineFont + "_" + taglineFontSize + taglineExtraConfig + ":" + encodeURIComponent(tagline), | ||
].join(','); | ||
"l_text:" + taglineFont + "_" + taglineFontSize + taglineExtraConfig + ":" + cleanText(tagline), | ||
].join(',') : undefined; | ||
// combine all the pieces required to generate a Cloudinary URL | ||
@@ -41,0 +51,0 @@ var urlParts = [ |
{ | ||
"name": "@jlengstorf/get-share-image", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "Jason Lengstorf <jason@lengstorf.com> (https://lengstorf.com)", |
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
10768
97