Skip to content

Commit d19f422

Browse files
committed
fix: include files that include []
1 parent 75cda48 commit d19f422

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/runtime/src/helpers/config.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ export const hasManuallyAddedModule = ({
9696
)
9797
/* eslint-enable camelcase */
9898

99+
/**
100+
* Transforms `/api/shows/[id].js` into `/api/shows/*id*.js`,
101+
* so that the file `[id].js` is matched correctly.
102+
*/
103+
const escapeGlob = (path: string) => path.replace(/\[/g, '*').replace(/]/g, '*')
104+
99105
export const configureHandlerFunctions = async ({
100106
netlifyConfig,
101107
publish,
@@ -173,7 +179,7 @@ export const configureHandlerFunctions = async ({
173179
netlifyConfig.functions[functionName] ||= { included_files: [] }
174180
netlifyConfig.functions[functionName].node_bundler = 'none'
175181
netlifyConfig.functions[functionName].included_files ||= []
176-
netlifyConfig.functions[functionName].included_files.push(...includedFiles)
182+
netlifyConfig.functions[functionName].included_files.push(...includedFiles.map(escapeGlob))
177183
}
178184
} else {
179185
configureFunction('_api_*')

0 commit comments

Comments
 (0)