Merge branch 'nanjekyejoannah-issue#1516'
This commit is contained in:
commit
29715ae7a7
@ -41,6 +41,8 @@ Added
|
||||
- New `:click-element` command to fake a click on a element.
|
||||
- New `:debug-log-filter` command to change console log filtering on-the-fly.
|
||||
- New `:debug-log-level` command to change the console loglevel on-the-fly.
|
||||
- New `general -> yank-ignored-url-parameters` option to configure which URL
|
||||
parameters (like `utm_source` etc.) to strip off when yanking an URL.
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
@ -168,11 +168,11 @@ Contributors, sorted by the number of commits in descending order:
|
||||
* Jimmy
|
||||
* Niklas Haas
|
||||
* Alexey "Averrin" Nabrodov
|
||||
* nanjekyejoannah
|
||||
* avk
|
||||
* ZDarian
|
||||
* Milan Svoboda
|
||||
* John ShaggyTwoDope Jenkins
|
||||
* nanjekyejoannah
|
||||
* Peter Vilim
|
||||
* Clayton Craft
|
||||
* Oliver Caldwell
|
||||
|
@ -10,6 +10,7 @@
|
||||
|Setting|Description
|
||||
|<<general-ignore-case,ignore-case>>|Whether to find text on a page case-insensitively.
|
||||
|<<general-startpage,startpage>>|The default page(s) to open at the start, separated by commas.
|
||||
|<<general-yank-ignored-url-parameters,yank-ignored-url-parameters>>|The URL parameters to strip with :yank url, separated by commas.
|
||||
|<<general-default-page,default-page>>|The page to open if :open -t/-b/-w is used without URL. Use `about:blank` for a blank page.
|
||||
|<<general-auto-search,auto-search>>|Whether to start a search when something else than a URL is entered.
|
||||
|<<general-auto-save-config,auto-save-config>>|Whether to save the config automatically on quit.
|
||||
@ -309,6 +310,12 @@ The default page(s) to open at the start, separated by commas.
|
||||
|
||||
Default: +pass:[https://duckduckgo.com]+
|
||||
|
||||
[[general-yank-ignored-url-parameters]]
|
||||
=== yank-ignored-url-parameters
|
||||
The URL parameters to strip with :yank url, separated by commas.
|
||||
|
||||
Default: +pass:[ref,utm_source,utm_medium,utm_campaign,utm_term,utm_content]+
|
||||
|
||||
[[general-default-page]]
|
||||
=== default-page
|
||||
The page to open if :open -t/-b/-w is used without URL. Use `about:blank` for a blank page.
|
||||
|
@ -25,7 +25,7 @@ import shlex
|
||||
import functools
|
||||
|
||||
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.QtPrintSupport import QPrintDialog, QPrintPreviewDialog
|
||||
try:
|
||||
@ -673,6 +673,20 @@ class CommandDispatcher:
|
||||
"Numeric argument is too large for internal int "
|
||||
"representation.")
|
||||
|
||||
def _yank_url(self, what):
|
||||
"""Helper method for yank() to get the URL to copy."""
|
||||
assert what in ['url', 'pretty-url'], what
|
||||
flags = QUrl.RemovePassword
|
||||
if what != 'pretty-url':
|
||||
flags |= QUrl.FullyEncoded
|
||||
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)
|
||||
return url.toString(flags)
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
@cmdutils.argument('what', choices=['selection', 'url', 'pretty-url',
|
||||
'title', 'domain'])
|
||||
@ -699,10 +713,7 @@ class CommandDispatcher:
|
||||
self._current_url().host(),
|
||||
':' + str(port) if port > -1 else '')
|
||||
elif what in ['url', 'pretty-url']:
|
||||
flags = QUrl.RemovePassword
|
||||
if what != 'pretty-url':
|
||||
flags |= QUrl.FullyEncoded
|
||||
s = self._current_url().toString(flags)
|
||||
s = self._yank_url(what)
|
||||
what = 'URL' # For printing
|
||||
elif what == 'selection':
|
||||
caret = self._current_widget().caret
|
||||
|
@ -139,6 +139,13 @@ def data(readonly=False):
|
||||
SettingValue(typ.List(typ.String()), 'https://duckduckgo.com'),
|
||||
"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 URL parameters to strip with :yank url, separated by "
|
||||
"commas."),
|
||||
|
||||
('default-page',
|
||||
SettingValue(typ.FuzzyUrl(), '${startpage}'),
|
||||
"The page to open if :open -t/-b/-w is used without URL. Use "
|
||||
|
@ -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
|
||||
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
|
||||
When I open data/title.html
|
||||
And I wait for regex "Changing title for idx \d to 'Test title'" in the log
|
||||
|
Loading…
Reference in New Issue
Block a user