Commit Graph

25 Commits

Author SHA1 Message Date
Chris Barber
5e6ef3d569 Enable source maps in tests (#10725)
The `tsconfig` files were unified with a common configuration in https://github.com/vercel/vercel/pull/10667 including disabling source maps. The source maps greatly increase the distribution size, but they are invaluable when the tests run, so this PR enables source maps for tests including adding a `tsconfig.json` where absent.

Linear: https://linear.app/vercel/issue/ZERO-364/enable-sourcemaps-in-all-testtsconfigjson-files
2023-10-17 15:15:29 +00:00
Felix Haus
9e9fac0191 [routing-utils] Adds support for statusCode property on rewrites (#10495)
Allows to define a `statusCode` property on `rewrites` in the same way as we already have it for `redirects`.
This is still blocked internally as it requires a feature flag to build with that setting.

So it would allow to set the status in `vercel.json` like this:
```json
{
  "rewrites": [
    {
      "source": "/*",
      "destination": "not-found.html",
      "statusCode": 404
    }
  ]
}

```

Once released, I'll update the documentation on that as well.

### Requirements
> Cause once router sees a status code is set, it stops routing.
> So it wont run the `miss` and `rewrite` sections again once it has a status.
> So just need to make sure wherever status code is set, its at the end of its routing.
> [[internal ref](https://vercel.slack.com/archives/C01A2M9R8RZ/p1691594782351809?thread_ts=1691540814.244679&cid=C01A2M9R8RZ)]
2023-10-13 10:03:36 +00:00
JJ Kasper
c2d0887b94 [next][routing-utils] Add missing matcher support (#8874)
### Related Issues

This adds handling to ensure we pass through the `missing` route field
correctly for custom routes and middleware matchers. Tests are also
added in the complimentary Next.js PR for this, example deployment can
be seen here
https://vtest314-e2e-tests-jj4-vtest314-next-e2e-tests.vercel.app/

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1667935428788529?thread_ts=1667850697.542269&cid=C03S8ED1DKM)
x-ref: https://github.com/vercel/next.js/pull/42660

### 📋 Checklist

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

#### Tests

- [ ] The code changed/added as part of this PR has been covered with
tests
- [ ] 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
2022-11-08 16:17:34 -08:00
Tobias Lins
4f8f8a5b98 [routing-utils] Allow to appendRoutes add null phase (#8814)
For Analytics V2 we need to append routes to the `null` phase instead of
`filesystem`.
2022-11-01 11:17:50 -04:00
Steven
181a492d91 [routing-utils] MAJOR refactor getTransformedRoutes and types (#8155)
This is a semver major change to the public API for `@vercel/routing-utils` which includes the following breaking changes.

1. `getTransformedRoutes({ nowConfig })` props changed to `getTransformedRoutes(nowConfig)`
2. `type Source` renamed `type RouteWithSrc`
3. `type Handler` renamed `type RouteWithHandle`
4. `interface VercelConfig` removed
5. `type NowConfig` removed
6. `type NowRewrite` removed
7. `type NowRedirect` removed
8. `type NowHeader` removed
9. `type NowHeaderKeyValue` removed
2022-07-15 14:05:08 -04:00
Nathan Rajlich
0d39dbd1d9 [routing-utils] Convert tests to TypeScript (#7959)
Allows for the tests to be run without rebuilding the source code.
2022-06-13 23:29:00 -07:00
Gal Schlezinger
f19690dc32 [build-utils] Add EdgeFunction output type (#7510)
Co-authored-by: Steven <steven@ceriously.com>
2022-03-08 18:58:26 +02:00
JJ Kasper
0f7e89f76c [routing-utils] Add caseSensitive field to routes schema (#6952)
### Related Issues

x-ref: https://github.com/vercel/customer-issues/issues/34

### 📋 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
2021-11-08 20:29:31 +00:00
Kiko Beats
981a76fbe2 [routing-utils] Add missing fields (#6872)
* chore: add missing fields

* Update types.ts

* Update types.ts

* chore add missing as part of the schema

* test: add missing case
2021-10-21 17:57:48 -05:00
Javi Velasco
2105d31730 Update middleware route (#6863) 2021-10-19 14:50:41 +02:00
JJ Kasper
dccacc4ca0 [routing-utils] Update routes schema for new property (#6860)
Adds an additional property for the `routes` schema. 

### Related Issues

N/A

### 📋 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
2021-10-18 21:45:42 +00:00
JJ Kasper
2fd3fc73e5 [routing-utils] Allow passing internal params to convertRewrites (#6742)
This adds an argument to allow passing internal param names that should be ignored when considering whether params should be auto-added to a rewrite's destination query. After adding this we should be able to resolve https://github.com/vercel/next.js/issues/27563 in the runtime where `convertRewrites` is called. 

This matches Next.js' handling for internal params which can be seen [here](e90825ad88/packages/next/shared/lib/router/utils/prepare-destination.ts (L203))

### Related Issues

x-ref: https://github.com/vercel/next.js/issues/27563

### 📋 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
2021-09-21 00:15:29 +00:00
JJ Kasper
90bacf88b8 [routing-utils] Fix host segment replacing (#6713)
* Fix host segment replacing

* Add additional check
2021-09-14 13:20:35 -05:00
JJ Kasper
b3ffcdf80d [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
2021-09-07 16:17:01 +00:00
JJ Kasper
232f55df22 Fix has segment validation in destination (#6521)
This ensures we validate segments being used from `has` in the `destination` correctly

### Related Issues

x-ref: https://vercel.slack.com/archives/CLDDX2Y0G/p1627285500281300

### 📋 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
2021-07-26 17:22:27 +00:00
Steven
bed83e829c [routing-utils] Fix rewrites with query string array in destination (#6441)
Related to https://github.com/vercel/next.js/pull/26619
2021-07-06 22:24:40 +00:00
JJ Kasper
adc84d5148 Fix check: true beforeFiles order (#6337) 2021-06-08 11:35:31 -05:00
JJ Kasper
e516c1f49f Ensure beforeFiles rewrites come after redirects when continuing (#6289) 2021-05-26 12:50:51 -05:00
JJ Kasper
01f53f36fc [routing-utils] Ensure header key value casing is normalized (#6284)
This ensures we normalize header `key` values in `has` items to be lower-case as the proxy currently only matches against the lower-case variant. Updated superstatic tests to ensure the header key is normalized correctly. 

### Related Issues

[related thread](https://vercel.slack.com/archives/C01N3RWTE5V/p1621937306006400)

### 📋 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
2021-05-25 22:46:28 +00:00
JJ Kasper
1dd2ffd895 Ensure segments from only has are replaced (#6142)
This ensures that when segments are coming from only `has` items we still replace them correctly as they currently don't get replaced if the `source` doesn't have any segments as well. 

### Related Issues

x-ref: https://vercel.slack.com/archives/CLDDX2Y0G/p1619061783470000

### 📋 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
2021-04-23 18:20:49 +00:00
JJ Kasper
d4db04207b Ensure has segments are replaced in destination (#6059)
* Ensure has segments are replaced in destination

* update type

* Use regex lexar for gathering named groups from has

* Update to use shared repo for regex lexer

* apply suggestions

* remove regexr from .eslintignore
2021-04-14 11:24:33 -05:00
Connor Davis
c6267b5acc [routing-utils] Add has type host to schema (#6022)
We need to support `{ "source": "/", "has": { "type", "host", "value": "vercel.com" }, "destination": "/prod" }`

#### 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

- [x] This PR has a concise title and thorough description useful to a reviewer
- [x] Issue from task tracker has a link to this PR

CH-19565
2021-03-22 20:37:27 +00:00
JJ Kasper
4969a65209 [routing-utils] Add has route field to schema (#5919)
### Related Issues

x-ref: https://github.com/vercel/next.js/pull/22341
x-ref: https://github.com/vercel/next.js/issues/22345

### 📋 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
2021-03-11 19:44:15 +00:00
Steven
f5f07c5d15 [all] Remove more "now" references (#5944)
Follow up to #5928 to remove a few more "now" references and replace with "vercel" where appropriate.
2021-03-08 10:08:09 -05:00
ernestd
cfae7ec3c2 [all] Remove now prefix in packages (#5928)
* remove prefix from codeowners

* remove references from ignore files

* Remove prefix from package json and tests

* Add run js without prefixes

* Rename package folders

* Delete auto generated test files

* Remove now-node in integration test

* Put back deleted vercel json files

* Remove eol

* Add styfle suggestion to comment in utils/run.js

Co-authored-by: Steven <steven@ceriously.com>
2021-03-05 16:55:30 -08:00