From 47faab5a525c50c9a9da310f0442eb4de3440973 Mon Sep 17 00:00:00 2001 From: yifang Date: Sat, 1 Jan 2022 21:09:55 +0800 Subject: [PATCH] fix:relative url redirect --- resources/gd_custom.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/gd_custom.js b/resources/gd_custom.js index 69e4742f..aaf0e423 100644 --- a/resources/gd_custom.js +++ b/resources/gd_custom.js @@ -2,12 +2,18 @@ $(function() { $("a").click(function(event) { var link = $(this).attr("href"); - if (link.indexOf("://") < 0) { - var newLink = window.location.href + "/" + link; - $(this).attr("href", newLink); + var newLink; + if (link.startsWith("#")) { + newLink = window.location.href + link; + } else { + var href = window.location.href; + var index = href.indexOf("?"); + newLink = href.substring(0, index) + "?word=" + link; } + $(this).attr("href", newLink); + }); } -); \ No newline at end of file +);