Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[now-dev] Fix route normalization #3225

Merged
merged 4 commits into from
Nov 1, 2019
Merged

Conversation

styfle
Copy link
Member

@styfle styfle commented Oct 30, 2019

This PR fixes a regression introduced in #3174 when removing the ^ and $ normalization.

The previous PR was normalizing user-defined routes but forgot to normalize builder routes.

This PR normalizes builder routes 馃憤

@styfle styfle removed the automerge label Oct 30, 2019
Copy link
Member

@TooTallNate TooTallNate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to add a test for this?

@styfle
Copy link
Member Author

styfle commented Nov 1, 2019

@TooTallNate I wrote a simple builder with a invalid regex route:

const { join, dirname } = require('path');
const { download, glob, shouldServe } = require('@now/build-utils');

async function build({ files, entrypoint, workPath, meta = {} }) {
  await download(files, workPath, meta);
  const mountpoint = dirname(entrypoint);
  const distPath = join(workPath, mountpoint);
  const routes = [{src: '(*.)', dest: '/index.html'}]; // broken regex
  const output = await glob('**', distPath, mountpoint);
  const watch = [join(mountpoint.replace(/^\.\/?/, ''), '**/*')];
  return { routes, output, watch };
};

module.exports =  { version: 2, build, shouldServe };

Then I added a now dev test fixture to ensure this builder fails with the correct error message.

@kodiakhq kodiakhq bot merged commit 2dee810 into canary Nov 1, 2019
@kodiakhq kodiakhq bot deleted the PRODUCT-341/fix-now-dev-normalize branch November 1, 2019 20:57
leo pushed a commit that referenced this pull request Nov 11, 2019
This PR fixes a regression introduced in #3174 when removing the `^` and `$` normalization.

The previous PR was normalizing user-defined routes but forgot to normalize builder routes.

This PR normalizes builder routes 馃憤
comus added a commit to withcloud/now that referenced this pull request Nov 23, 2019
* commit 'ba18a3a0cbada71104184d2fdb9b3d9bde48a193': (161 commits)
  [now-cli] Add note for Windows environment variable syntax (vercel#3243)
  [docs] Rename "Builders" to "Runtimes" (vercel#3256)
  Update Public Directory Link (vercel#3221)
  Publish
  [now-next] 404 Known Static Files Before Dynamic Routes (vercel#3238)
  Publish
  [now-cli] Adjust `now ls` according to new project overview (vercel#3229)
  [now dev] Add support for `cleanUrls` (vercel#3240)
  [now-cli] Fix test invalid-builder-routes (vercel#3249)
  [now-cli] Remove `now upgrade` command (vercel#3228)
  [now-dev] Fix route normalization (vercel#3225)
  Publish
  [now-build-utils] Fix custom function runtimes (vercel#3239)
  Publish
  [now-cli][now-client] Add support for `functions` property (vercel#3231)
  Publish
  Fix racing spinners (vercel#3232)
  Publish
  [now-routing-utils] Fix newline in error message (vercel#3234)
  [now-build-utils] Fix zero config trailing slash (vercel#3233)
  ...

# Conflicts:
#	packages/now-node/package.json
#	packages/now-node/src/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants