// Extracted from https://github.com/ember-fastboot/ember-cli-fastboot/blob/909c1417ceeb8a5c92bb952b0d59be02bfdca546/packages/fastboot/src/ember-app.js#L406-L420 // Discussion in https://github.com/ember-fastboot/fastboot/pull/85 const JSON_ESCAPE = { '&': '\\u0026', '>': '\\u003e', '<': '\\u003c', '\u2028': '\\u2028', '\u2029': '\\u2029' }; const JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/g; function escapeJSONString(string) { return string.replace(JSON_ESCAPE_REGEXP, function(match) { return JSON_ESCAPE[match]; }); }