Update index.js

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

View file

@ -5,8 +5,13 @@ document.addEventListener("DOMContentLoaded", () => {
const statusMessage = document.getElementById("status-message");
const errorMessage = document.getElementById("error-message");
// Helper function to normalize URLs (removes trailing slashes)
const normalizeUrl = (url) => url.replace(/\/+$/, "").trim();
// Helper function to normalize URLs (removes trailing slashes, query parameters, and fragments)
const normalizeUrl = (url) => {
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 the root domain from a URL
function extractRootDomain(url) {