Skip to content

Commit

Permalink
spaceが入ってた時の検索を改善
Browse files Browse the repository at this point in the history
  • Loading branch information
new-sankaku authored Oct 5, 2024
1 parent 515cc1d commit 602876a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ <h4>Search Result <button id="copy-button">Tag Copy</button><span id="search-sta

function searchTags() {
const searchInput = document.getElementById('search-input').value;
const searchTerms = searchInput.split('\n').filter(term => term.trim() !== '');
const searchTerms = searchInput.split('\n')
.filter(term => term.trim() !== '')
.map(term => term.trim().replace(/\s+/g, '_'));
const resultsDiv = document.getElementById('results');

if (searchTerms.length === 0) {
Expand All @@ -155,9 +157,10 @@ <h4>Search Result <button id="copy-button">Tag Copy</button><span id="search-sta

searchTerms.forEach(term => {
tags.forEach(tag => {
if (tag.n === term) {
const normalizedTag = tag.n.replace(/\s+/g, '_');
if (normalizedTag === term) {
matches.set(tag.n, { ...tag, exact: true });
} else if (tag.n.includes(term) && !matches.has(tag.n)) {
} else if (normalizedTag.includes(term) && !matches.has(tag.n)) {
matches.set(tag.n, { ...tag, exact: false });
}
});
Expand Down

0 comments on commit 602876a

Please sign in to comment.