Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Ignore files and directories with leading dots except .well-known #254

Merged
merged 1 commit into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/create_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Route } from '../interfaces';
export default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: locations.routes(), dot: true, nodir: true }) }) {
const routes: Route[] = files
.map((file: string) => {
if (/(^|\/|\\)_/.test(file)) return;
if (/(^|\/|\\)(_|\.(?!well-known))/.test(file)) return;

if (/]\[/.test(file)) {
throw new Error(`Invalid route ${file} — parameters must be separated`);
Expand Down
11 changes: 11 additions & 0 deletions test/unit/create_routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
const a = create_routes({
files: ['foo/[bar].html', '[baz]/qux.html']
Expand Down