From 305def8c03f4990c40b837ca317898e08162b374 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Sat, 18 May 2024 12:09:03 -0400 Subject: [PATCH] fix(sdk): cannot use relative paths for container images (#6518) The `isPath` utility didn't take into account `../` as an option. Meh! ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- libs/wingsdk/src/shared/misc.ts | 2 +- libs/wingsdk/test/misc.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 libs/wingsdk/test/misc.test.ts diff --git a/libs/wingsdk/src/shared/misc.ts b/libs/wingsdk/src/shared/misc.ts index d87cfb5a332..be6e2975219 100644 --- a/libs/wingsdk/src/shared/misc.ts +++ b/libs/wingsdk/src/shared/misc.ts @@ -51,5 +51,5 @@ export async function shell( export function isPath(s: string) { s = normalPath(s); - return s.startsWith("./") || s.startsWith("/"); + return s.startsWith("./") || s.startsWith("../") || s.startsWith("/"); } diff --git a/libs/wingsdk/test/misc.test.ts b/libs/wingsdk/test/misc.test.ts new file mode 100644 index 00000000000..43ae07e8029 --- /dev/null +++ b/libs/wingsdk/test/misc.test.ts @@ -0,0 +1,10 @@ +import { expect, test } from "vitest"; +import { isPath } from "../src/shared/misc"; + +test("isPath", () => { + expect(isPath("foo")).toBeFalsy(); + expect(isPath("./hello")).toBeTruthy(); + expect(isPath("../hello")).toBeTruthy(); + expect(isPath(".././../hello")).toBeTruthy(); + expect(isPath("/hello/world")).toBeTruthy(); +});