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

address-barbrowsercharacter encoding

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

Best Answer

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.


Related Question