How to stop Chrome from turning relative links to absolute links on copy/paste?


Staff member
I'm copying rich text from a
and pasting it to a <a href="" rel="noreferrer">Medium</a> draft. Most of the formatting is preserved fine, but for some reason I don't understand all relative links are converted to absolute ones. I don't know on what step this happens. I even thought Medium could be listening to "paste" events. This would be the worst case scenario, because I'd have very little control over it. But if so, how do they have access to the URL of the page I was when I copied the content? Indeed, after checking with other browsers, I concluded it's Chrome's fault, and not Medium's. On Safari it works perfectly, on Firefox it doesn't work at all (but that's a topic for another question…).

To make things more clear, I'm trying to mimic the behavior of the <a href="" rel="noreferrer">footnotes plugin</a> I use on my Wordpress blog by writing a bookmarklet that does essentially the same.

Here's a demo page where you can paste text with a wiki-like syntax for inline references and parse them into proper footnotes:

<a href="" rel="noreferrer"></a>

In both modes of usage ([1] copy/pasting to the demo page or [2] using the bookmarklet), the resulting html has proper relative links. However, after pasting back to Medium on Chrome, they become absolute, pointing to
and breaking the functionality.

If I run the code from my local machine instead of
, however, the links are kept in relative form after paste even on Chrome.

What could possibly be going on? Is there any way to fix it?