[routing-utils] Ensure headers with only has items are replaced correctly (#6686)

This ensures we replace header values correctly when no named segments are used and only has items are used. 

### Related Issues

Fixes: https://vercel.slack.com/archives/CHTTGQYQ4/p1631023974185700

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
This commit is contained in:
JJ Kasper
2021-09-07 11:17:01 -05:00
committed by GitHub
parent 43c1a93c1d
commit b3ffcdf80d
2 changed files with 33 additions and 1 deletions

View File

@@ -112,7 +112,7 @@ export function convertHeaders(headers: Header[]): Route[] {
});
h.headers.forEach(({ key, value }) => {
if (namedSegments.length > 0) {
if (namedSegments.length > 0 || hasSegments.length > 0) {
if (key.includes(':')) {
key = safelyCompile(key, indexes);
}