From 76edff5ce870867ebce817c9dff3b947e59bf816 Mon Sep 17 00:00:00 2001 From: dabico Date: Tue, 26 Mar 2024 11:00:26 +0100 Subject: [PATCH] Extract string normalization to a partial script --- views/conflict.ejs | 9 +-------- views/label.ejs | 9 +-------- views/partials/scripts/normalize.ejs | 9 +++++++++ views/review.ejs | 9 +-------- 4 files changed, 12 insertions(+), 24 deletions(-) create mode 100644 views/partials/scripts/normalize.ejs diff --git a/views/conflict.ejs b/views/conflict.ejs index d9cc9fb..1806ba7 100644 --- a/views/conflict.ejs +++ b/views/conflict.ejs @@ -331,6 +331,7 @@ <%- include('./partials/footer'); %> <%- include('./partials/scripts/general'); %> + <%- include('./partials/scripts/normalize') %> <%- include('./partials/scripts/hljs'); %> \ No newline at end of file diff --git a/views/review.ejs b/views/review.ejs index 8d52d07..97ac74b 100644 --- a/views/review.ejs +++ b/views/review.ejs @@ -211,6 +211,7 @@ <%- include('./partials/footer'); %> <%- include('./partials/scripts/general'); %> + <%- include('./partials/scripts/normalize') %> <%- include('./partials/scripts/hljs'); %> <% if (!!reviewer && !!instance) { %> @@ -234,14 +235,6 @@ const refresh = () => history.go(); const toast = (element) => new bootstrap.Toast(element).show(); - const normalize = (name) => { - const coalesced = name ?? ""; - const normalized = coalesced.replaceAll(/\s+/g, " "); - const lowercase = normalized.toLowerCase(); - const trimmed = lowercase.trim(); - return (trimmed.length === 0) ? null : trimmed; - }; - const addOption = (label) => { const search = normalize(labelFilter.value); const options = labelInstanceSelect.options;