From 0ef84fedf18cbb4b8b97d256105c636fd2e87193 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 22 Sep 2020 19:56:49 -0400 Subject: [PATCH] Proposal: unmatched optional path segments should be `undefined` in props Fixes #381. --- src/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 8bd989c9..d4bfbec2 100644 --- a/src/util.js +++ b/src/util.js @@ -30,12 +30,12 @@ export function exec(url, route, opts) { flags = (route[i].match(/[+*?]+$/) || EMPTY)[0] || '', plus = ~flags.indexOf('+'), star = ~flags.indexOf('*'), - val = url[i] || ''; + val = url[i]; if (!val && !star && (flags.indexOf('?')<0 || plus)) { ret = false; break; } - matches[param] = decodeURIComponent(val); + matches[param] = val && decodeURIComponent(val); if (plus || star) { matches[param] = url.slice(i).map(decodeURIComponent).join('/'); break;