Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Don't use regex to split query string since this doesn't work correctly in IE8 #567

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions platforms/Bower/Durandal/js/plugins/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up, might not be a problem. This makes ?foo= be

foo: ''

and ?foo

foo: null

Before both of these became

foo: undefined

Could have some unwanted effects, not sure though. Depends how that data is handled further.

I used this in a local patch I made.

    var parts = pair.split('='),
      key = parts.shift(),
      rest = parts.join('=') || undefined
      value = rest && decodeURIComponent(rest.replace(/\+/g, ' '));


var existing = queryObject[key];

Expand Down
6 changes: 3 additions & 3 deletions platforms/HTML/Samples/lib/durandal/js/plugins/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down
6 changes: 3 additions & 3 deletions platforms/HTML/StarterKit/lib/durandal/js/plugins/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,9 @@ define(['durandal/system', 'durandal/app', 'durandal/activator', 'durandal/event
continue;
}

var parts = pair.split(/=(.+)?/),
key = parts[0],
value = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
var sp = pair.indexOf("="),
key = sp === -1 ? pair : pair.substr(0, sp),
value = sp === -1 ? null : decodeURIComponent(pair.substr(sp + 1).replace(/\+/g, ' '));

var existing = queryObject[key];

Expand Down