Skip to content

Commit

Permalink
fix: more specific ignore regex default (#88)
Browse files Browse the repository at this point in the history
* Fix ignore of requests with extensions

Before this change: If a URL happens to contain a `.` but it's not a request to a file, it'll be ignored (a 404 is returned). E.g. http://localhost:5000/51.89768130456134,-8.470441788798238. 

The regex now only matches if the path contains valid filename characters all the way from the slash til the end, not just at the end.

* Update index.js

* fix: update `ignore` regexp;

- still follows slash
- still disallows comma-delimited segment
- fix: allows any number of dot-delimited segments

Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
  • Loading branch information
adam-lynch and lukeed authored Dec 5, 2020
1 parent 478b487 commit 5e3d7a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/sirv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function (dir, opts={}) {

let ignores = [];
if (opts.ignores !== false) {
ignores.push(/\w\.\w+$/); // any extn
ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/); // any extn
if (opts.dotfiles) ignores.push(/\/\.\w/);
else ignores.push(/\/\.well-known/);
[].concat(opts.ignores || []).forEach(x => {
Expand Down

0 comments on commit 5e3d7a8

Please sign in to comment.