Skip to content

Commit

Permalink
Merge pull request #11118 from elplancton/host-regex
Browse files Browse the repository at this point in the history
feat(core): add support to named groups
  • Loading branch information
kamilmysliwiec committed Apr 17, 2023
2 parents bc4a571 + df74cde commit b908f1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/router/router-explorer.ts
Expand Up @@ -292,7 +292,13 @@ export class RouterExplorer {
for (const exp of hostRegExps) {
const match = hostname.match(exp.regexp);
if (match) {
exp.keys.forEach((key, i) => (req.hosts[key.name] = match[i + 1]));
if (exp.keys.length > 0) {
exp.keys.forEach((key, i) => (req.hosts[key.name] = match[i + 1]));
} else if (exp.regexp && match.groups) {
for (const groupName in match.groups) {
req.hosts[groupName] = match.groups[groupName];
}
}
return handler(req, res, next);
}
}
Expand Down

0 comments on commit b908f1a

Please sign in to comment.