Skip to content

Commit

Permalink
fix: correctly parse platform, filename from file URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jhso-dev committed Jun 16, 2024
1 parent c0f9b7e commit 1bf4c7c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/repack/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,20 @@ async function runAdbReverse(ctx: Server.DelegateContext, port: number) {
}

function parseFileUrl(fileUrl: string) {
const { pathname: filename, searchParams } = new URL(fileUrl);
const { pathname, searchParams } = new URL(fileUrl);
let platform = searchParams.get('platform');
let filename = pathname;

if (!platform) {
const pathArray = pathname.split('/');
const platformFromPath = pathArray[1];

if (platformFromPath === 'ios' || platformFromPath === 'android') {
platform = platformFromPath;
filename = pathArray.slice(2).join('/');
}
}

if (!platform) {
const [, platformOrName, name] = filename.split('.').reverse();
if (name !== undefined) {
Expand Down

0 comments on commit 1bf4c7c

Please sign in to comment.