Skip to content

Commit

Permalink
Fixed potential issues with Array.prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary committed Feb 19, 2015
1 parent f299b39 commit 1dc79ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
13 changes: 8 additions & 5 deletions dist/lightrouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
run: function() {
var url = this.getUrl(), route;

for (var i in this.routes)
for (var i = 0, len = this.routes.length; i < len; i++)
{
// Get the route
route = this.routes[i];
Expand Down Expand Up @@ -236,11 +236,14 @@
t = 1;
params = route.match(this.router.namedParam.match);
}
for (i in params)

if (params)
{
name = t ? params[i].replace(this.router.namedParam.match, '$1') : i;
obj[name] = values[i];
for (var i = 0, len = params.length; i < len; i++)
{
name = t ? params[i].replace(this.router.namedParam.match, '$1') : i;
obj[name] = values[i];
}
}

return obj;
Expand Down
2 changes: 1 addition & 1 deletion dist/lightrouter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/lightrouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
run: function() {
var url = this.getUrl(), route;

for (var i in this.routes)
for (var i = 0, len = this.routes.length; i < len; i++)
{
// Get the route
route = this.routes[i];
Expand Down Expand Up @@ -236,11 +236,14 @@
t = 1;
params = route.match(this.router.namedParam.match);
}
for (i in params)

if (params)
{
name = t ? params[i].replace(this.router.namedParam.match, '$1') : i;
obj[name] = values[i];
for (var i = 0, len = params.length; i < len; i++)
{
name = t ? params[i].replace(this.router.namedParam.match, '$1') : i;
obj[name] = values[i];
}
}

return obj;
Expand Down

0 comments on commit 1dc79ab

Please sign in to comment.