fix: wrangle urls
This commit is contained in:
parent
c1e0088942
commit
8e0119b2f7
5 changed files with 17 additions and 8 deletions
|
@ -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'
|
||||
|
|
Reference in a new issue