How to stop Chrome from turning relative links to absolute links on copy/paste?
<p>I'm copying rich text from a <code>div</code> with <code>contenteditable="true"</code> and pasting it to a <a href="https://medium.com" 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…).</p>

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

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

<p><a href="https://rawgit.com/arielpontes/footnoter/master/index.html" rel="noreferrer">https://rawgit.com/arielpontes/footnoter/master/index.html</a></p>

<p>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 <code>rawgit.com</code> and breaking the functionality.</p>

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

<p>What could possibly be going on? Is there any way to fix it?</p>