From a0ac603260353072ed1ae56b173b8fbdfda53297 Mon Sep 17 00:00:00 2001 From: soulsands <407221377@qq.com> Date: Sat, 8 Apr 2023 21:07:48 +0800 Subject: [PATCH] fix:Remove duplicates in character class --- src/public/app/services/utils.js | 10 +++++----- src/services/attribute_formatter.js | 6 +++--- src/services/search/services/search.js | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/public/app/services/utils.js b/src/public/app/services/utils.js index 49edcf5ec..e0ef2d767 100644 --- a/src/public/app/services/utils.js +++ b/src/public/app/services/utils.js @@ -29,7 +29,7 @@ function formatTimeWithSeconds(date) { // this is producing local time! function formatDate(date) { -// return padNum(date.getDate()) + ". " + padNum(date.getMonth() + 1) + ". " + date.getFullYear(); + // return padNum(date.getDate()) + ". " + padNum(date.getMonth() + 1) + ". " + date.getFullYear(); // instead of european format we'll just use ISO as that's pretty unambiguous return formatDateISO(date); @@ -45,7 +45,7 @@ function formatDateTime(date) { } function localNowDateTime() { - return dayjs().format('YYYY-MM-DD HH:mm:ss.SSSZZ') + return dayjs().format('YYYY-MM-DD HH:mm:ss.SSSZZ'); } function now() { @@ -101,7 +101,7 @@ async function stopWatch(what, func) { } function formatValueWithWhitespace(val) { - return /[^\w_-]/.test(val) ? `"${val}"` : val; + return /[^\w-]/.test(val) ? `"${val}"` : val; } function formatLabel(label) { @@ -318,7 +318,7 @@ function initHelpDropdown($el) { initHelpButtons($dropdownMenu); } -const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/" +const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/"; function openHelp(e) { window.open(wikiBaseUrl + $(e.target).attr("data-help-page"), '_blank'); @@ -329,7 +329,7 @@ function initHelpButtons($el) { // so we do it manually $el.on("click", e => { if ($(e.target).attr("data-help-page")) { - openHelp(e) + openHelp(e); } }); } diff --git a/src/services/attribute_formatter.js b/src/services/attribute_formatter.js index 8891a7813..c8a9c1de6 100644 --- a/src/services/attribute_formatter.js +++ b/src/services/attribute_formatter.js @@ -1,4 +1,4 @@ -"use strict" +"use strict"; function formatAttrForSearch(attr, searchWithValue) { let searchStr = ''; @@ -28,7 +28,7 @@ function formatAttrForSearch(attr, searchWithValue) { } function formatValue(val) { - if (!/[^\w_]/.test(val)) { + if (!/[^\w]/.test(val)) { return val; } else if (!val.includes('"')) { @@ -47,4 +47,4 @@ function formatValue(val) { module.exports = { formatAttrForSearch -} +}; diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index 4b4f2110e..f1adc72d7 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -73,7 +73,7 @@ function searchFromRelation(note, relationName) { return []; } - const result = scriptService.executeNote(scriptNote, { originEntity: note }); + const result = scriptService.executeNote(scriptNote, {originEntity: note}); if (!Array.isArray(result)) { log.info(`Result from ${scriptNote.noteId} is not an array.`); @@ -288,7 +288,7 @@ function searchNotesForAutocomplete(query) { noteTitle: beccaService.getNoteTitle(result.noteId), notePathTitle: result.notePathTitle, highlightedNotePathTitle: result.highlightedNotePathTitle - } + }; }); } @@ -370,7 +370,7 @@ function formatAttribute(attr) { let label = `#${utils.escapeHtml(attr.name)}`; if (attr.value) { - const val = /[^\w_-]/.test(attr.value) ? `"${attr.value}"` : attr.value; + const val = /[^\w-]/.test(attr.value) ? `"${attr.value}"` : attr.value; label += `=${utils.escapeHtml(val)}`; }