prevent URL length limit errors

Closes #829
main
Mike Fix 5 years ago
parent b519723931
commit d60e556b5b

@ -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
}

Loading…
Cancel
Save