diff --git a/client/commonFramework/bindings.js b/client/commonFramework/bindings.js index 8f1aaa044..9eb8e74b1 100644 --- a/client/commonFramework/bindings.js +++ b/client/commonFramework/bindings.js @@ -21,6 +21,11 @@ window.common = (function(global) { }; common.init.push(function($) { + function stripTrailingHashes(url) { + let i = url.length - 1; + while (i >= 0 && url[i] === '#') i--; + return url.slice(0, i + 1); + } var $marginFix = $('.innerMarginFix'); $marginFix.css('min-height', $marginFix.height()); @@ -179,10 +184,9 @@ window.common = (function(global) { }); $('#search-issue').on('click', function() { - var queryIssue = window.location.href - .toString() - .split('?')[0] - .replace(/(#*)$/, ''); + var queryIssue = stripTrailingHashes( + window.location.href.toString().split('?')[0] + ); window.open( 'https://github.com/freecodecampchina/freecodecamp.cn/issues?q=' + 'is:issue is:all ' + @@ -196,4 +200,4 @@ window.common = (function(global) { }); return common; -}(window)); +}(window)); \ No newline at end of file diff --git a/client/commonFramework/init.js b/client/commonFramework/init.js index ff4130efd..6b8bcc15e 100644 --- a/client/commonFramework/init.js +++ b/client/commonFramework/init.js @@ -46,13 +46,13 @@ window.common = (function(global) { }; common.replaceFormActionAttr = function replaceFormAction(value) { - return value.replace(/