Skip to content

Commit

Permalink
Review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffposnick committed Jan 10, 2017
1 parent e2845a1 commit 7215ef6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/sw-routing/src/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,19 @@ class Router {
}

const matchResult = route.match({url, event});
if (matchResult || matchResult === 0 || matchResult === '') {
responsePromise = route.handler.handle({
url,
event,
params: matchResult,
});
if (matchResult) {
let params = matchResult;

if (Array.isArray(params) && params.length === 0) {
// Instead of passing an empty array in as params, use undefined.
params = undefined;
} else if (params.constructor === Object &&
Object.keys(params).length === 0) {
// Instead of passing an empty object in as params, use undefined.
params = undefined;
}

responsePromise = route.handler.handle({url, event, params});
break;
}
}
Expand Down

0 comments on commit 7215ef6

Please sign in to comment.