diff --git a/src/plugins/router/router.js b/src/plugins/router/router.js
index 37e143c..3a1c5af 100644
--- a/src/plugins/router/router.js
+++ b/src/plugins/router/router.js
@@ -137,7 +137,8 @@ export default function({ $data, addScopeToNode, directive, magic, reactive }) {
|| e.shiftKey
|| e.defaultPrevented
|| e.button > 0
- || is_blank) {
+ || is_blank
+ || is_external(link)) {
return;
}
@@ -191,7 +192,7 @@ export default function({ $data, addScopeToNode, directive, magic, reactive }) {
//
if (link) {
- return router.history.resolve(link.href) === router.values.path;
+ return !is_external(link) && router.history.resolve(link.href) === router.values.path;
}
if (el._r_routerlink_init) {
@@ -215,6 +216,16 @@ function is_anchor_element(el) {
return el.tagName.toUpperCase() === "A";
}
+//
+// A link to another origin or a non-HTTP scheme, such as "mailto:" or "tel:",
+// leads outside the application and is left to the browser.
+// The protocol and host are compared instead of the origin,
+// which browsers report differently for file: URLs ("null" or "file://").
+//
+function is_external(link) {
+ return link.protocol !== location.protocol || link.host !== location.host;
+}
+
function get_anchor_element(el) {
if (is_anchor_element(el)) {
return el;
diff --git a/tests/playwright/assets/page.html b/tests/playwright/assets/page.html
index b7bbe68..e39714e 100644
--- a/tests/playwright/assets/page.html
+++ b/tests/playwright/assets/page.html
@@ -20,6 +20,7 @@
+