1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 23:05:10 +01:00

Implemented stripping of query parameters from url

This commit is contained in:
2016-08-02 13:07:24 +02:00
parent d5c6b751f9
commit 607a45ca8b
2 changed files with 12 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ import requests
import shutil
import bs4
from more_itertools import unique_everseen
from urlparse import urlparse
from urlparse import urlparse, urlunparse
from utilkit import datetimeutil
@@ -156,6 +156,11 @@ class Bookmark(db.Model):
tags_clean = clean_tags(tags_split)
self.tags = ','.join(tags_clean)
@classmethod
def strip_url_params(cls, url):
parsed = urlparse(url)
return urlunparse((parsed.scheme, parsed.netloc, parsed.path, parsed.params, '', parsed.fragment))
@property
def tags_list(self):
""" Get the tags as a list, iterable in template """
@@ -283,6 +288,9 @@ def updatebookmark(userkey, request, urlhash = None):
starred = False
if request.form.get('starred'):
starred = True
strip_params = False
if request.form.get('strip'):
strip_params = True
if url and not urlhash:
# New bookmark
@@ -300,6 +308,8 @@ def updatebookmark(userkey, request, urlhash = None):
return None
bookmark.title = title
if strip_params:
url = Bookmark.strip_url_params(url)
bookmark.url = url
bookmark.starred = starred
bookmark.set_tags(tags)

View File

@@ -88,7 +88,7 @@
<div class="input-field col s12">
<input type="checkbox" name="strip" id="strip" />
<label for="strip">Strip parameters from url</label>
<label for="strip">Strip parameters from url (like <em>?utm_source=social</em> - can break the link!)</label>
</div>
{% if bookmark.url_hash %}