From 4dab630a1b28ec1dea5449488ef8d30e77b60253 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 21 Aug 2018 15:35:37 -0700 Subject: [PATCH] Fix issue where we were sometimes filtering out certain node modules innapropriately. (#1807) --- sdk/nodejs/runtime/closure/codePaths.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sdk/nodejs/runtime/closure/codePaths.ts b/sdk/nodejs/runtime/closure/codePaths.ts index 67489eac3..d162644a1 100644 --- a/sdk/nodejs/runtime/closure/codePaths.ts +++ b/sdk/nodejs/runtime/closure/codePaths.ts @@ -79,8 +79,13 @@ export async function computeCodePaths( function isSubsumedByHigherPath(path: string, pathSet: Set): boolean { for (const otherPath of pathSet) { - if (path.length > otherPath.length && path.startsWith(otherPath)) { - return true; + if (path.length > otherPath.length && + path.startsWith(otherPath)) { + + // Have to make sure we're actually a sub-directory of that other path. For example, + // if we have: node_modules/mime-types, that's not subsumed by node_modules/mime + const nextChar = path.charAt(otherPath.length); + return nextChar === "/" || nextChar === "\\"; } }