Add general -> yank-ignored-url-parameters

This commit is contained in:
nanjekyejoannah 2016-08-24 16:17:09 +03:00 committed by Florian Bruhin
parent e77bf62ace
commit d3e19ec8fc
3 changed files with 26 additions and 2 deletions

View File

@ -25,7 +25,7 @@ import shlex
import functools import functools
from PyQt5.QtWidgets import QApplication, QTabBar from PyQt5.QtWidgets import QApplication, QTabBar
from PyQt5.QtCore import Qt, QUrl, QEvent from PyQt5.QtCore import Qt, QUrl, QEvent, QUrlQuery
from PyQt5.QtGui import QKeyEvent from PyQt5.QtGui import QKeyEvent
from PyQt5.QtPrintSupport import QPrintDialog, QPrintPreviewDialog from PyQt5.QtPrintSupport import QPrintDialog, QPrintPreviewDialog
try: try:
@ -702,7 +702,13 @@ class CommandDispatcher:
flags = QUrl.RemovePassword flags = QUrl.RemovePassword
if what != 'pretty-url': if what != 'pretty-url':
flags |= QUrl.FullyEncoded flags |= QUrl.FullyEncoded
s = self._current_url().toString(flags) url = QUrl(self._current_url())
url_query = QUrlQuery(url)
for key in dict(url_query.queryItems()):
if key in config.get('general', 'yank-ignored-url-parameters'):
url_query.removeQueryItem(key)
url.setQuery(url_query)
s = url.toString(flags)
what = 'URL' # For printing what = 'URL' # For printing
elif what == 'selection': elif what == 'selection':
caret = self._current_widget().caret caret = self._current_widget().caret

View File

@ -139,6 +139,12 @@ def data(readonly=False):
SettingValue(typ.List(typ.String()), 'https://duckduckgo.com'), SettingValue(typ.List(typ.String()), 'https://duckduckgo.com'),
"The default page(s) to open at the start, separated by commas."), "The default page(s) to open at the start, separated by commas."),
('yank-ignored-url-parameters',
SettingValue(typ.List(typ.String()), 'ref,utm_source,'
'utm_medium,utm_campaign,utm_term,utm_content'),
"The default parameters to strip on yank,"
" separated by commas."),
('default-page', ('default-page',
SettingValue(typ.FuzzyUrl(), '${startpage}'), SettingValue(typ.FuzzyUrl(), '${startpage}'),
"The page to open if :open -t/-b/-w is used without URL. Use " "The page to open if :open -t/-b/-w is used without URL. Use "

View File

@ -20,6 +20,18 @@ Feature: Yanking and pasting.
Then the message "Yanked URL to primary selection: http://localhost:(port)/data/title.html" should be shown Then the message "Yanked URL to primary selection: http://localhost:(port)/data/title.html" should be shown
And the primary selection should contain "http://localhost:(port)/data/title.html" And the primary selection should contain "http://localhost:(port)/data/title.html"
Scenario: Yanking URLs with ref and UTM parameters
When I open data/title.html?utm_source=kikolani&utm_medium=320banner&utm_campaign=bpp&ref=facebook
And I run :yank
Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title.html" should be shown
And the clipboard should contain "http://localhost:(port)/data/title.html"
Scenario: Yanking URLs with ref and UTM parameters and some other parameters
When I open data/title.html?stype=models&utm_source=kikolani&utm_medium=320banner&utm_campaign=bpp&ref=facebook
And I run :yank
Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title.html?stype=models" should be shown
And the clipboard should contain "http://localhost:(port)/data/title.html?stype=models"
Scenario: Yanking title to clipboard Scenario: Yanking title to clipboard
When I open data/title.html When I open data/title.html
And I wait for regex "Changing title for idx \d to 'Test title'" in the log And I wait for regex "Changing title for idx \d to 'Test title'" in the log