Function: isSameOrigin()
ts
function isSameOrigin(urlA, urlB): boolean;Checks whether two URLs share the same origin (scheme + host + port). 判断两个 URL 是否同源(协议 + 主机 + 端口)。
Parameters
| Parameter | Type | Description |
|---|---|---|
urlA | string | First URL / 第一个 URL |
urlB | string | Second URL / 第二个 URL |
Returns
boolean
True when origins match / 同源则为 true
Example
ts
isSameOrigin('https://a.com/x', 'https://a.com/y') // => trueSince
1.0.0