Skip to content

Commit

Permalink
fix(title): replace first negative tag (minus) with empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Oct 19, 2022
1 parent 6d66df0 commit 570087c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions assets/js/SeoHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ export class SeoHelper {
return null
}

const CAPITALIZED_TAGS = tags.map((tag) => capitalize(tag)).join(', ')

return this.normalizeStringForTitle(CAPITALIZED_TAGS)
return tags
.map((tag) => capitalize(tag))
.map((tag) => SeoHelper.normalizeStringForTitle(tag))
.join(', ')
}

static normalizeStringForTitle(title) {
if (!title) {
static normalizeStringForTitle(string) {
if (!string) {
return null
}

title = title.trim()
string = string.trim()

// Delete first negative tag (minus)
string = string.startsWith('-') ? string.substr(1) : string

// Replace underscores with spaces
title = title.replace(/_/g, ' ')
string = string.replace(/_/g, ' ')

// Replace parentheses with empty string
title = title.replace(/\(/g, '')
title = title.replace(/\)/g, '')
// Delete parentheses
string = string.replace(/\(/g, '')
string = string.replace(/\)/g, '')

// Replace colon with empty string
title = title.replace(/:/g, '')
// Delete colons
string = string.replace(/:/g, '')

return title
return string
}
}

0 comments on commit 570087c

Please sign in to comment.