mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-20 14:25:07 +00:00
Merge branch 'master' of github.com:sveltejs/sapper
This commit is contained in:
@@ -6,7 +6,7 @@ import { Route } from '../interfaces';
|
|||||||
export default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: locations.routes(), dot: true, nodir: true }) }) {
|
export default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: locations.routes(), dot: true, nodir: true }) }) {
|
||||||
const routes: Route[] = files
|
const routes: Route[] = files
|
||||||
.map((file: string) => {
|
.map((file: string) => {
|
||||||
if (/(^|\/|\\)_/.test(file)) return;
|
if (/(^|\/|\\)(_|\.(?!well-known))/.test(file)) return;
|
||||||
|
|
||||||
if (/]\[/.test(file)) {
|
if (/]\[/.test(file)) {
|
||||||
throw new Error(`Invalid route ${file} — parameters must be separated`);
|
throw new Error(`Invalid route ${file} — parameters must be separated`);
|
||||||
|
|||||||
@@ -150,6 +150,17 @@ describe('create_routes', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignores files and directories with leading dots except .well-known', () => {
|
||||||
|
const routes = create_routes({
|
||||||
|
files: ['.well-known', '.unknown']
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
routes.map(r => r.file),
|
||||||
|
['.well-known']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('matches /foo/:bar before /:baz/qux', () => {
|
it('matches /foo/:bar before /:baz/qux', () => {
|
||||||
const a = create_routes({
|
const a = create_routes({
|
||||||
files: ['foo/[bar].html', '[baz]/qux.html']
|
files: ['foo/[bar].html', '[baz]/qux.html']
|
||||||
|
|||||||
Reference in New Issue
Block a user