Concepts
Canonical URL identity check
Compare parsed components, not raw string spelling. The example performs no navigation.
Formal Syntax & Structure
javascript syntaxjavascript
parsed.protocol === expectedProtocol && parsed.origin === expectedOriginWorking Example
Example Snippetjavascript
(async () => {const u=new URL("https://SHOP.example:443/account");console.log(u.origin,u.pathname,u.origin==="https://shop.example");})()