Automatically removes leading and trailing spaces from tags because tags

are often entered with a space after each comma.
This uses .trim() in func.render_tags() to remove when rendering as well
as .map(str => str.trim()) when a post or post edit is submitted so they
are also stored without spaces.
This commit is contained in:
2025-09-07 22:11:58 +01:00
parent e3e5469e1a
commit 09967a0be9
2 changed files with 3 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ export function render_tags(tags) {
}
else {
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
string += `<a href="/tag/${tags[tag_index]}">${tags[tag_index]}</a>` // Adds the tag to the string as a HTML href
string += `<a href="/tag/${tags[tag_index].trim()}">${tags[tag_index].trim()}</a>` // Adds the tag to the string as a HTML href
if (tag_index < tags.length - 1) { // If there are more tags, then insert a comma
string += ", ";
}