diff --git a/lib/routing.js b/lib/routing.js index f28d05d..a255da5 100644 --- a/lib/routing.js +++ b/lib/routing.js @@ -3,6 +3,7 @@ import url from 'url' import { escapeHtml } from './util' +const URL_LIMIT = 4e3 const mapper = new Morph({ types: { bool: v => { @@ -29,7 +30,12 @@ const mapper = new Morph({ encode: v => { if (v == null) return undefined try { - return encodeURIComponent(v) + const encoded = encodeURIComponent(v) + if (encoded.length > URL_LIMIT) { + // soft prevent URL length limit errors https://github.com/dawnlabs/carbon/issues/829 + return encodeURIComponent(v.slice(0, URL_LIMIT / 2)) + } + return encoded } catch (e) { return v }