1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-12-02 06:24:11 +01:00

Try to correct query string url for search in bookmark

This commit is contained in:
Brice Maron 2012-05-08 16:22:35 +00:00
parent d5a90dd8e9
commit 756c03d8ef

View File

@ -120,13 +120,20 @@ function showBookmark(event) {
}, 500); }, 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) { function updateBookmarksList(bookmark) {
var tags = encodeEntities(bookmark.tags).split(' '); var tags = encodeEntities(bookmark.tags).split(' ');
var taglist = ''; var taglist = '';
for ( var i=0, len=tags.length; i<len; ++i ){ for ( var i=0, len=tags.length; i<len; ++i ){
if(tags[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)) { if(!hasProtocol(bookmark.url)) {
bookmark.url = 'http://' + bookmark.url; bookmark.url = 'http://' + bookmark.url;