Skip to content

Commit

Permalink
Merge pull request #255 from maciek134/fix/254-fix-url-error
Browse files Browse the repository at this point in the history
fix: url service error
  • Loading branch information
lurock committed May 4, 2020
2 parents 1ffd50f + cfe8208 commit dc2f546
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions projects/playground/src/lib/core/shared/url.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ export class UrlService {
private parse(key: string, sandboxMenuItems: SandboxMenuItem[], urlPath: string) {
const match = new RegExp('[?|&]' + key + '=([^&#]*)').exec(urlPath);
if (match !== null) {
const value = match[1];
const firstSlash = value.indexOf('/');
const value = decodeURIComponent(match[1]);
const lastSlash = value.lastIndexOf('/');

const sbKey = value.substr(0, firstSlash);
let sandboxKey = decodeURIComponent(sbKey);
const sbKey = value.substr(0, lastSlash);
let sandboxKey = sbKey;
const sandboxMenuItem = sandboxMenuItems
.find(smi => smi.key.toLowerCase() === sandboxKey.toLowerCase()
|| (smi.uniqueId && smi.uniqueId === sandboxKey));
sandboxKey = sandboxMenuItem.key;
if (!sandboxMenuItem) {
return { sandboxKey: null, scenarioKey: null };
}
const scenarioDesc = decodeURIComponent(value.substr(firstSlash + 1, value.length).toLowerCase());
const scenarioDesc = value.substr(lastSlash + 1, value.length).toLowerCase();
const scenarioKey = sandboxMenuItem.scenarioMenuItems
.findIndex(scenarioMenuItem => scenarioMenuItem.description.toLowerCase() === scenarioDesc) + 1;
if (scenarioKey <= 0) {
Expand Down

0 comments on commit dc2f546

Please sign in to comment.