diff --git a/packages/plugins/src/SharedConfigPlugin.ts b/packages/plugins/src/SharedConfigPlugin.ts index 0f3e68d7..ccc75e25 100644 --- a/packages/plugins/src/SharedConfigPlugin.ts +++ b/packages/plugins/src/SharedConfigPlugin.ts @@ -9,6 +9,16 @@ function createFileGlob(url, pageExtensions) { return `${url}{${pageExtensions.join(',')}}`; } +/** + * https://stackoverflow.com/a/50549047 + * compute inner relative to outer + * If it's not contained, the first component of the resulting path will be .., so that's what we check for + */ +function isWithin(outer, inner) { + const rel = path.posix.relative(outer, inner); + return !rel.startsWith('../') && rel !== '..'; +} + interface SharedConfigPluginPage extends Page { sharedConfig?: string; } @@ -35,8 +45,14 @@ const SharedConfigPlugin: PluginType