fix: wrangle urls

This commit is contained in:
Cory Dransfeldt 2023-08-04 13:17:00 -07:00
parent c1e0088942
commit 8e0119b2f7
No known key found for this signature in database
5 changed files with 17 additions and 8 deletions

View file

@ -12,6 +12,15 @@ module.exports = {
return marked.parse(content)
},
dashLower: (string) => string.replace(/\s+/g, '-').toLowerCase(),
encodeAmp: (string) => {
const pattern = /&(?!(?:[a-zA-Z]+|#[0-9]+|#x[0-9a-fA-F]+);)/g
const replacement = '&'
return string.replace(pattern, replacement)
},
stripUtm: (string) => {
const pattern = /[?&](utm_[^&=]+=[^&#]*)/gi
return string.replace(pattern, '')
},
getPostImage: (image) => {
if (image && image !== '') return image
return '/assets/img/social-card.webp'