From 360568f61dcc8c064ad447e2284f7d64c245ba31 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 24 Aug 2022 09:40:28 -0400 Subject: [PATCH 1/2] typo --- packages/kit/types/internal.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/types/internal.d.ts b/packages/kit/types/internal.d.ts index 7786b946d2bb..1d870c4ba64f 100644 --- a/packages/kit/types/internal.d.ts +++ b/packages/kit/types/internal.d.ts @@ -155,7 +155,7 @@ export interface Respond { } /** - * Represents a route segement in the app. It can either be an intermediate node + * Represents a route segment in the app. It can either be an intermediate node * with only layout/error pages, or a leaf, at which point either `page` and `leaf` * or `endpoint` is set. */ From 2d44a06fc03c137c483cc41a2d157c6b25f7be9c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 24 Aug 2022 09:43:51 -0400 Subject: [PATCH 2/2] prefer positive over negative predicate names --- packages/kit/src/core/sync/create_manifest_data/index.js | 4 ++-- packages/kit/src/utils/routing.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/kit/src/core/sync/create_manifest_data/index.js b/packages/kit/src/core/sync/create_manifest_data/index.js index 57e4b6ec630d..aa10db01d13d 100644 --- a/packages/kit/src/core/sync/create_manifest_data/index.js +++ b/packages/kit/src/core/sync/create_manifest_data/index.js @@ -3,7 +3,7 @@ import path from 'path'; import mime from 'mime'; import { runtime_directory } from '../../utils.js'; import { posixify } from '../../../utils/filesystem.js'; -import { parse_route_id, is_no_group } from '../../../utils/routing.js'; +import { parse_route_id, affects_path } from '../../../utils/routing.js'; /** * @param {{ @@ -247,7 +247,7 @@ function create_routes_and_nodes(cwd, config, fallback) { nodes.push(route.leaf); - const normalized = route.id.split('/').filter(is_no_group).join('/'); + const normalized = route.id.split('/').filter(affects_path).join('/'); if (conflicts.has(normalized)) { throw new Error(`${conflicts.get(normalized)} and ${route.id} occupy the same route`); diff --git a/packages/kit/src/utils/routing.js b/packages/kit/src/utils/routing.js index 5f6dbd4fbc4f..3ff8c92443cb 100644 --- a/packages/kit/src/utils/routing.js +++ b/packages/kit/src/utils/routing.js @@ -26,7 +26,7 @@ export function parse_route_id(id) { : new RegExp( `^${id .split(/(?:\/|$)/) - .filter(is_no_group) + .filter(affects_path) .map((segment, i, segments) => { const decoded_segment = decodeURIComponent(segment); // special case — /[...rest]/ could contain zero segments @@ -89,9 +89,10 @@ export function parse_route_id(id) { } /** + * Returns `false` for `(group)` segments * @param {string} segment */ -export function is_no_group(segment) { +export function affects_path(segment) { return !/^\([^)]+\)$/.test(segment); }