is_external_url: support relative URLs (#4449)

Follows up on #4405
This commit is contained in:
Aarni Koskela 2023-06-08 14:17:29 +03:00 committed by GitHub
parent fd2538bd05
commit 94f0267d8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,7 @@
## Bug Fixes:
No changes to highlight.
- Frontend code no longer crashes when there is a relative URL in an `<a>` element, by [@akx](https://github.com/akx) in [PR 4449](https://github.com/gradio-app/gradio/pull/4449).
## Other Changes:

View File

@ -321,14 +321,14 @@
}
};
const is_external_url = (link: string | null) =>
link && new URL(link, location.href).origin !== location.origin;
async function handle_mount() {
await tick();
var a = target.getElementsByTagName("a");
const is_external_url = (link: string | null) =>
link && new URL(link).origin !== location.origin;
for (var i = 0; i < a.length; i++) {
const _target = a[i].getAttribute("target");
const _link = a[i].getAttribute("href");