From 83abec6015edce47355ec0b122af3bea37ec0ee8 Mon Sep 17 00:00:00 2001 From: Boris Kubiak Date: Mon, 27 Apr 2020 19:08:35 +0200 Subject: [PATCH] Handle long content better --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e9379db..5d5ecc7 100644 --- a/index.js +++ b/index.js @@ -128,7 +128,9 @@ const openInNewTab = () => { // Build a shareable URL const buildUrl = (rawData, mode) => { - const url = `${location.protocol}//${location.host}/` + rawData + `?lang=${encodeURIComponent(select.selected())}`; + const base = `${location.protocol}//${location.host}/`; + const query = `?lang=${encodeURIComponent(select.selected())}`; + const url = rawData.length <= 4000 ? base + rawData + query : base + query + '#' + rawData; if (mode === 'markdown') { return `[NoPaste snippet](${url})`; }