Update background.js

Updated RegEx
This commit is contained in:
Kenneth Hendricks 2024-11-01 16:36:14 -04:00 committed by GitHub
parent 782ea1ea38
commit 1f88becc79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,9 +28,12 @@ function extractUrlsFromBookmarks(html) {
return urls;
}
// Helper function to normalize URLs (removes trailing slashes)
// Helper function to normalize URLs (removes trailing slashes, query parameters, and fragments)
function normalizeUrl(url) {
return url.replace(/\/+$/, ""); // Remove trailing slash only, no www. removal
const urlObj = new URL(url);
urlObj.search = ""; // Remove query parameters
urlObj.hash = ""; // Remove fragments
return urlObj.href.replace(/\/+$/, ""); // Remove trailing slash only
}
// Helper function to extract root domain from URL