Skip to content

Commit 2a114c7

Browse files
committed
add yankencodedurl option
1 parent f391670 commit 2a114c7

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

common/content/browser.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,21 @@ const Browser = Module("browser", {
9696
options.add(["urlseparator"],
9797
"Set the separator regex used to separate multiple URL args",
9898
"string", ",\\s");
99+
100+
options.add(["yankencodedurl"],
101+
"Set the yank mode copying encoded URL",
102+
"boolean", false);
99103
},
100104

101105
mappings: function () {
102106
mappings.add([modes.NORMAL],
103107
["y"], "Yank current location to the clipboard",
104108
function () {
105-
var url = services.get("textToSubURI").unEscapeURIForUI(buffer.charset, buffer.URL);
109+
var url = buffer.URL;
110+
if (options.get("yankencodedurl").value)
111+
url = services.get("io").newURI(url, buffer.charser, null).asciiSpec;
112+
else
113+
url = services.get("textToSubURI").unEscapeURIForUI(buffer.charset, url).replace(/ /g, "%20");
106114
util.copyToClipboard(url, true);
107115
});
108116

common/content/services.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ const Services = Module("services", {
7070
class_: "@mozilla.org/intl/texttosuburi;1",
7171
iface: Ci.nsITextToSubURI
7272
},
73+
"io": {
74+
class_: "@mozilla.org/network/io-service;1",
75+
iface: Ci.nsIIOService
76+
},
7377
};
7478

7579
this.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);

common/locale/en-US/options.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,16 @@
13951395
</description>
13961396
</item>
13971397

1398+
<item>
1399+
<tags>'yankencodedurl'</tags>
1400+
<spec>'yankencodedurl'</spec>
1401+
<type>boolean</type>
1402+
<default>false</default>
1403+
<description>
1404+
<p>Set the yank mode for copying URLs. By default, only whitespace charaters are replaced by %20 to make pasting in other apps easy. If yankencodedurl is <str>true</str>, any non-ASCII character is URL encoded as well.</p>
1405+
</description>
1406+
</item>
1407+
13981408
<item>
13991409
<tags> 'ani' 'animations'</tags>
14001410
<spec> 'animations' 'ani'</spec>

vimperator/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
XXXX-XX-XX
2+
* When you copy the URL with y, copy it as-is with only space encoded as %20
3+
* Add 'yankencodedurl' option, so you can get the old behavior to encode any
4+
any non-ASCII character with the encoded character
5+
16
2013-11-22
27
* version 3.8.1
38
* Fix arrow keys in menus

0 commit comments

Comments
 (0)