07509923 days ago21 lines · 712 B| 1 | /** GitHub's callback rule: same scheme, host and port as the registered callback, and a path equal to its path or under it. */ |
| 2 | export function callbackMatches(registered |
| 3 | if (given.includes |
| 4 | let callback: |
| 5 | let redirect: |
| 6 | try { |
| 7 | callback = new |
| 8 | redirect = new |
| 9 | } catch { |
| 10 | return false; |
| 11 | } |
| 12 | if (redirect.username |
| 13 | if (redirect.origin |
| 14 | const base = |
| 15 | ? callback.pathname |
| 16 | : `${callback.pathname |
| 17 | return ( |
| 18 | redirect.pathname === |
| 19 | redirect.pathname.startsWith |
| 20 | ); |
| 21 | } |