Skip to content

Commit

Permalink
fix path formatting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Oct 11, 2024
1 parent fe96733 commit 2d0e14a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pxtsim/simdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ namespace pxsim {
} else {
const simUrl = this.getSimUrl();
// Ensure we preserve upload target path (/app/<sha>---simulator)
const simPath = simUrl.pathname.replace(/---?.*/, "");
// Construct the path. The "-" element delineates the extension key from the resource name.
const simxPath = [simPath, "simx", key, "-", simx.index].join("/");
let simPath = simUrl.pathname.replace(/---?.*/, "");
// Remove leading and trailing slashes
simPath = simPath.replace(/^\/+|\/+$/, "");
// Construct the path. The "-" element delineates the extension key from the resource name
let simxPath = [simPath, "simx", key, "-", simx.index].join("/");
// Append a leading slash to `simxPath` unless it already has one (if `simPath` was an empty string then it will already have a leading slash)
simxPath = simxPath.startsWith("/") ? simxPath : `/${simxPath}`;
simx.url = new URL(simxPath, simUrl.origin).toString();
}

Expand Down

0 comments on commit 2d0e14a

Please sign in to comment.