下の表で URL A と URL B が同一オリジンかブラウザの URL.origin 判定で即時確認できます。
★ 行 3〜5 は典型的な罠 (サブドメイン / スキーム違い / 省略ポート)。
| # | URL A | URL B | 結果 | origin(A) | origin(B) |
|---|---|---|---|---|---|
| 1 | https://example.com | https://example.org | |||
| 2 | https://example.com/hoge | https://example.com/fuga | |||
| 3 | https://foo.example.com/test | http://bar.example.com/test | |||
| 4 | https://example.com/test | http://example.com/test | |||
| 5 | https://example.com | https://example.com:443 |
※ 判定は new URL(value).origin の単純比較です。