Skip to content

Commit

Permalink
refactor(index): convert unused capture groups to non-capture groups (#…
Browse files Browse the repository at this point in the history
…318)

* docs(readme): update regex examples

* refactor(index): convert unused capture groups to non-capture groups
  • Loading branch information
Fdawgs authored Jul 9, 2023
1 parent 9fd002e commit a871da5
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ Autoload can be customised using the following options:
```js
fastify.register(autoLoad, {
dir: path.join(__dirname, 'plugins'),
ignorePattern: /.*(test|spec).js/
ignorePattern: /^.*(?:test|spec).js$/
})
```
@@ -144,7 +144,7 @@ Autoload can be customised using the following options:
```js
fastify.register(autoLoad, {
dir: path.join(__dirname, 'plugins'),
indexPattern: /.*routes(\.ts|\.js|\.cjs|\.mjs)$/
indexPattern: /^.*routes(?:\.ts|\.js|\.cjs|\.mjs)$/
})
```
@@ -228,7 +228,7 @@ Autoload can be customised using the following options:
fastify.register(autoLoad, {
dir: path.join(__dirname, 'plugins'),
autoHooks: true,
autoHooksPattern: /^[_.]?auto_?hooks(\.js|\.cjs|\.mjs)$/i
autoHooksPattern: /^[_.]?auto_?hooks(?:\.js|\.cjs|\.mjs)$/i
})
```
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@ const routeParamPattern = /\/_/ig
const routeMixedParamPattern = /__/g

const defaults = {
scriptPattern: /((^.?|\.[^d]|[^.]d|[^.][^d])\.ts|\.js|\.cjs|\.mjs)$/i,
indexPattern: /^index(\.ts|\.js|\.cjs|\.mjs)$/i,
autoHooksPattern: /^[_.]?auto_?hooks(\.ts|\.js|\.cjs|\.mjs)$/i,
scriptPattern: /(?:(?:^.?|\.[^d]|[^.]d|[^.][^d])\.ts|\.js|\.cjs|\.mjs)$/i,
indexPattern: /^index(?:\.ts|\.js|\.cjs|\.mjs)$/i,
autoHooksPattern: /^[_.]?auto_?hooks(?:\.ts|\.js|\.cjs|\.mjs)$/i,
dirNameRoutePrefix: true,
encapsulate: true
}
2 changes: 1 addition & 1 deletion types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ const opt7: AutoloadPluginOptions = {
dir: 'test',
forceESM: true,
autoHooks: true,
autoHooksPattern: /^[_.]?auto_?hooks(\.js|\.cjs|\.mjs)$/i,
autoHooksPattern: /^[_.]?auto_?hooks(?:\.ts|\.js|\.cjs|\.mjs)$/i,
cascadeHooks: true,
overwriteHooks: true,
}

0 comments on commit a871da5

Please sign in to comment.