Add scheme failsafe to all inventory URL link buttons
If a stored URL is missing http:// or https:// the browser treats it as relative and appends it to the app URL. Guard in three places: - inventory-catalog-lookup.js syncLinkButton: ensureAbsoluteUrl() prepends https:// - inventory-label-scan.js syncLink: same guard for scan-filled URL fields - Details.cshtml SafeUrl() Razor helper on SpecPageUrl, SdsUrl, TdsUrl links Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -413,10 +413,15 @@
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
function ensureAbsoluteUrl(url) {
|
||||
if (!url) return url;
|
||||
return /^https?:\/\//i.test(url) ? url : 'https://' + url;
|
||||
}
|
||||
|
||||
function syncLinkButton(inputId, linkId, url) {
|
||||
const link = document.getElementById(linkId);
|
||||
if (!link) return;
|
||||
if (url) { link.href = url; link.classList.remove('d-none'); }
|
||||
if (url) { link.href = ensureAbsoluteUrl(url); link.classList.remove('d-none'); }
|
||||
else { link.classList.add('d-none'); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user