Skip to content

Commit

Permalink
Fixes Issue mtrpcic#39. A bit simpler than sforster’s proposal in df6…
Browse files Browse the repository at this point in the history
…8106df68106, but missing tests because could not get the line endings right on that file, so should use his
  • Loading branch information
Sean DeNigris committed Jul 25, 2014
1 parent 2fe037d commit 1e760c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 7 additions & 5 deletions path.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var Path = {
}
},
'match': function (path, parameterize) {
var params = {}, route = null, possible_routes, slice, i, j, compare;
var params = {}, route = null, possible_routes, slice, i, j, compare, compare_parts;
for (route in Path.routes.defined) {
if (route !== null && route !== undefined) {
route = Path.routes.defined[route];
Expand All @@ -63,9 +63,11 @@ var Path = {
compare = path;
if (slice.search(/:/) > 0) {
for (i = 0; i < slice.split("/").length; i++) {
if ((i < compare.split("/").length) && (slice.split("/")[i].charAt(0) === ":")) {
params[slice.split('/')[i].replace(/:/, '')] = compare.split("/")[i];
compare = compare.replace(compare.split("/")[i], slice.split("/")[i]);
compare_parts = compare.split("/");
if ((i < compare_parts.length) && (slice.split("/")[i].charAt(0) === ":")) {
params[slice.split('/')[i].replace(/:/, '')] = compare_parts[i];
compare_parts[i] = slice.split("/")[i];
compare = compare_parts.join("/");
}
}
}
Expand Down Expand Up @@ -189,4 +191,4 @@ Path.core.route.prototype = {
Path.routes.defined[this.path].action();
}
}
};
};
8 changes: 7 additions & 1 deletion path.min.js

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

0 comments on commit 1e760c2

Please sign in to comment.