Skip to content

Commit

Permalink
simpler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Oct 11, 2024
1 parent 2d0e14a commit 9b16390
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pxtsim/simdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,11 @@ namespace pxsim {
} else {
const simUrl = this.getSimUrl();
// Ensure we preserve upload target path (/app/<sha>---simulator)
let simPath = simUrl.pathname.replace(/---?.*/, "");
// Remove leading and trailing slashes
simPath = simPath.replace(/^\/+|\/+$/, "");
const simPath = simUrl.pathname.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();
const simxPath = [simPath, "simx", key, "-", simx.index].join("/");
// Create the fully-qualified URL, preserving the origin by removing all leading slashes
simx.url = new URL(simxPath.replace(/^\/+/, ""), simUrl.origin).toString();
}

// Add the origin to the allowed origins
Expand Down

0 comments on commit 9b16390

Please sign in to comment.