Why when copying a non-English URL from address bar it's URL encoded and not as the text I see (decoded)?

When I copy a link from the address bar that has characters that needs to be encoded usually, the copied link will contain the encoded text and not the decoded (which is what's visually seen).

But if I edit (and revert) something in the URL, such as adding space and deleting it - the copied text would be decoded.

Why this is the behavior? Any reason behind it, or arbitrary?

Note: From what I've checked - this is the behavior on Chrome and Firefox, but not Edge (which will copy the text decoded).

Is there a way to change the behavior and always copy the (nice) decoded URL?
(At least for Chrome)


Example:

Browsing this address will display https://he.wikipedia.org/wiki/עוגייה in the address bar, but when copied, will copy https://he.wikipedia.org/wiki/%D7%A2%D7%95%D7%92%D7%99%D7%99%D7%94.
Editing something before copying will change this behavior.

enter image description here


Solution 1:

The URL encoded format is the form actually used by applications that communicate on the web. It is copied from Firefox/Chrome this way by default to likely guarantee the usability of the copied URL.

The reason the URL "changes" when edited is almost certainly because the browser has detected differences in the URL string, which would potentially need to be encoded again.

Is there a way to change the behavior and always copy the (nice) decoded URL (at least for Chrome)?

Firefox

This Super User question has an answer that states you can set the value of browser.urlbar.decodeURLsOnCopy to True under about:config in Firefox 53+ to automatically copy the non-URL encoded form of a URL. This worked for me, though I did not test it on the most recent versions of Firefox.

Chrome

Updated December 2019

I didn't find any internal settings for Chrome, but I did find a recommendation on Stack Overflow for a Chrome extension called Copy Unicode URLs (last updated January 2019 at the time of this update) that seemed to copy your example URL without encoding, as advertised.

As a small caveat regarding this extension, while links embedded in pages had a Copy unicode URL option in the right-click menu, "address bar" URLs had to be copied by left-clicking the Copy Unicode URLs extension icon placed to the right of the omnibox (near the Settings menu).


If you are on Windows, it's also probably worth noting that you can paste a group of URL encoded URLs into Notepad++, choose Edit → Select All (Ctrl+A) and then (assuming you have the default plugins available) use Plugins → MIME Tools → URL Decode to decode all the URLs at once.


Solution 2:

It is a deliberately implemented and very useful feature of web browsers:

  • Upon issuing a copy command for the whole URL, the web browser encodes it into that form certain form. You do that by a single click on the address bar. The cue is that the whole address bar is selected.
  • If you first opt to select part of the URL (even if then you end up selecting all of it) the web browser just copies what you see. You do that by a single click, followed by another single click (or just a double click), then selecting what you want.

There is also a part that you may not realize: When entering https://he.wikipedia.org/wiki/עוגייה, the web browser converts it into https://he.wikipedia.org/wiki/%D7%A2%D7%95%D7%92%D7%99%D7%99%D7%94 in the background before transmitting it online.

All of this have a reason. I'll spare you the details and just give you the bottom line: The encoded URL is the real URL. The "nice" URL, as you put it, is just something to simplify the life for you. As such, the latter might not work in all web-enabled apps, while the former is guaranteed to work.

Addendum: You might not even be able to properly send the "nice" URL via email, instant messaging or SMS! It really depends on whether the service you use and your recipient uses support Unicode. (Gmail, Hotmail, Skype and Telegram are okay. I'm not sure about Sprint, Verizon or AT&T's SMS service.)

Solution 3:

You may use an extension like https://chrome.google.com/webstore/detail/copy-unicode-urls/fnbbfiapefhkicjhecnoepbijhanpkjp that allows you to copy the URL without encoding.