bloomreach-experience-react-sdk
Advanced tools
Comparing version 0.5.1 to 0.5.2
{ | ||
"name": "bloomreach-experience-react-sdk", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "BloomReach Experience SDK for React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -464,2 +464,5 @@ # BloomReach Experience SDK for React | ||
### Version 0.5.2 | ||
- Fixed bug with query string affecting on the path parsing. | ||
### Version 0.5.1 | ||
@@ -466,0 +469,0 @@ - Fixed bug with preview update on the component properties dialog changes; |
@@ -8,3 +8,3 @@ import globalCmsUrls from './cms-urls'; | ||
const urlPath = request.path; | ||
const [urlPath, query = ''] = request.path.split('?', 2); | ||
let hostname = request.hostname; | ||
@@ -17,3 +17,3 @@ // remove port number from hostname | ||
// detect if in CMS/preview mode | ||
let preview = hasPreviewQueryParameter(urlPath); | ||
let preview = hasPreviewQueryParameter(query); | ||
if (!preview) { | ||
@@ -37,5 +37,3 @@ preview = isMatchingPreviewHostname(hostname, cmsUrls); | ||
path = results[pathIdx + 1] !== undefined ? results[pathIdx + 1] : ''; | ||
// query parameter is not needed for fetching API URL and can actually conflict with component rendering URLs | ||
path = removeQueryParameter(path); | ||
if (!preview) { | ||
@@ -47,28 +45,10 @@ // otherwise use preview-prefix in URL-path to detect preview mode | ||
return { | ||
path: path, | ||
preview: preview, | ||
query: urlPath.split('?', 2)[1] || '', | ||
}; | ||
return { path, preview, query }; | ||
} | ||
function hasPreviewQueryParameter(urlPath) { | ||
const queryStringIdx = urlPath.indexOf('?'); | ||
if (queryStringIdx !== -1) { | ||
const queryString = urlPath.substring(queryStringIdx); | ||
if (queryString.indexOf('?bloomreach-preview=true') !== -1 || queryString.indexOf('&bloomreach-preview=true') !== -1) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
function hasPreviewQueryParameter(query) { | ||
return query.startsWith('bloomreach-preview=true') | ||
|| query.indexOf('&bloomreach-preview=true') !== -1; | ||
} | ||
function removeQueryParameter(urlPath) { | ||
const queryStringIdx = urlPath.indexOf('?'); | ||
if (queryStringIdx !== -1) { | ||
return urlPath.substring(0, urlPath.indexOf('?')); | ||
} | ||
return urlPath; | ||
} | ||
// if hostname is different for preview and live, | ||
@@ -75,0 +55,0 @@ // then hostname can be used to detect if we're in preview mode |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
273086
540
1371
6