From ebccd48013b20a7d72486b46a479d49c5c5f2d32 Mon Sep 17 00:00:00 2001 From: manto89 Date: Wed, 21 Jun 2023 18:05:41 +0200 Subject: [PATCH] Don't search note by url if url begins with 'about:' --- src/routes/api/clipper.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.js index 310735985..636d94e21 100644 --- a/src/routes/api/clipper.js +++ b/src/routes/api/clipper.js @@ -16,17 +16,20 @@ const htmlSanitizer = require('../../services/html_sanitizer'); const {formatAttrForSearch} = require("../../services/attribute_formatter"); function findClippingNote(clipperInboxNote, pageUrl) { - const notes = clipperInboxNote.searchNotesInSubtree( - formatAttrForSearch({ - type: 'label', - name: "pageUrl", - value: pageUrl - }, true) - ); + //Avoid searching for empty of browser pages like about:blank + if (pageUrl.trim().length > 1 && pageUrl.trim().indexOf('about:') != 0 ){ + const notes = clipperInboxNote.searchNotesInSubtree( + formatAttrForSearch({ + type: 'label', + name: "pageUrl", + value: pageUrl + }, true) + ); - for (const note of notes) { - if (note.getOwnedLabelValue('clipType') === 'note') { - return note; + for (const note of notes) { + if (note.getOwnedLabelValue('clipType') === 'note') { + return note; + } } }