diff options
-rw-r--r-- | apps/bookmarks/js/bookmarks.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js index b1eebaa5515..73986e49186 100644 --- a/apps/bookmarks/js/bookmarks.js +++ b/apps/bookmarks/js/bookmarks.js @@ -120,13 +120,20 @@ function showBookmark(event) { }, 500); } +function replaceQueryString(url,param,value) { + var re = new RegExp("([?|&])" + param + "=.*?(&|$)","i"); + if (url.match(re)) + return url.replace(re,'$1' + param + "=" + value + '$2'); + else + return url + '&' + param + "=" + value; +} function updateBookmarksList(bookmark) { var tags = encodeEntities(bookmark.tags).split(' '); var taglist = ''; for ( var i=0, len=tags.length; i<len; ++i ){ if(tags[i] != '') - taglist = taglist + '<a class="bookmark_tag" href="?tag=' + encodeURIComponent(tags[i]) + '">' + tags[i] + '</a> '; + taglist = taglist + '<a class="bookmark_tag" href="'+replaceQueryString( String(window.location), 'tag', encodeURIComponent(tags[i])) + '">' + tags[i] + '</a> '; } if(!hasProtocol(bookmark.url)) { bookmark.url = 'http://' + bookmark.url; |