从浏览器的地址栏复制一个 UTF-8 URL,只给出一个丑陋的编码 URL

当我从浏览器的地址栏(几乎任何操作系统上的浏览器)复制一个 UTF-8 URL,然后尝试将其粘贴到另一个文本字段(例如发布到 Facebook 或 Twitter 上) ,它只提供解码后的 URL,这使得它很难看。例如,在地址栏中,URL 显示如下:

Https://www.chaino.com/وذكر

但是,当试图复制粘贴到任何其他地方时,它会显示下面这个难看的网址:

Https://www.chaino.com/%d9%88%d8%b0%d9%83%d8%b1

(如果我想得到原始的网址在任何地方使用它,我用这个 原始 URL 解码器-在线工具解码它)

问题是: 有没有一种简单直接的方法来复制这种 URL,并且不用这种可怕的过程就可以粘贴它?(可能使用铬扩展或其他东西)

29525 次浏览

The best answer I found tell now is using this Chrome extension: https://chrome.google.com/webstore/detail/copy-cyrilic-urls/alnknpnpinldhpkjkgobkalmoaeolhnf?hl=en-US

which enables me to copy the url (in a decoded state) with only one click :)

The URI you get by copying from the address bar is the only valid URI the browser can give you.

From the RFC 3986 (and other URL RFCs):

A URI is a sequence of characters from a very limited set: the letters of the basic Latin alphabet, digits, and a few special characters.

So: https://www.chaino.com/وذكر Is an invalid URI, yet a valid IRI (International Resource Identifier), that your browser will convert to a valid URI while requesting the server over HTTP (HTTP does not allow IRI, only URI).

TL;DR: Your browser is giving you what you expect: A valid URI that you can use everywhere, not an IRI only supported here and here.

PS If "facebook or twitter for example" are kind, they may display a readable form to their users, so don't worry about giving an encoded form.

You can select URL without selecting scheme (e.g. http://), and copy it. This will give you what you expected.

P.S. The point is to select only part of the link. E.g. you can select whole URL without first character and than add it manually.

You can add a 'space' at the end of the URL in the address bar, then you can select it all and copy it directly.

In Firefox 53+ you can set browser.urlbar.decodeURLsOnCopy about:config option to true.

Create a bookmark with this url: javascript:console.log(prompt('copy (Control+C) this link:', decodeURIComponent(window.location))).

Click this bookmark on that page.

Example page: https://www.google.com.hk/search?q=中文

You can use Chrome and FireFox extension called "Copy Unicode URLs", which I created. It is:

  1. Open source.
  2. Gives you an option to leave URL terminators encoded so, e.g., links that end with a dot will have that dot encoded and email clients won't wrongly recognize this dot as a sentence/URL terminator.

If you love my work then, please, donate some sum here.

Copy addres without 'h' in http... And past addres without 'h' and sum first addres with 'h'