|
|
@ -3,6 +3,7 @@ import url from 'url'
|
|
|
|
|
|
|
|
|
|
|
|
import { escapeHtml } from './util'
|
|
|
|
import { escapeHtml } from './util'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const URL_LIMIT = 4e3
|
|
|
|
const mapper = new Morph({
|
|
|
|
const mapper = new Morph({
|
|
|
|
types: {
|
|
|
|
types: {
|
|
|
|
bool: v => {
|
|
|
|
bool: v => {
|
|
|
@ -29,7 +30,12 @@ const mapper = new Morph({
|
|
|
|
encode: v => {
|
|
|
|
encode: v => {
|
|
|
|
if (v == null) return undefined
|
|
|
|
if (v == null) return undefined
|
|
|
|
try {
|
|
|
|
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) {
|
|
|
|
} catch (e) {
|
|
|
|
return v
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
}
|
|
|
|