Skip to content

Commit

Permalink
fix: correctly parse platform from file URL (callstack#647)
Browse files Browse the repository at this point in the history
* fix: correctly parse platform, filename from file URL

* chore: add changeset

---------

Co-authored-by: Jakub Romańczyk <jakub.romanczyk@callstack.com>
  • Loading branch information
jhso-dev and jbroma authored Jul 25, 2024
1 parent a14d693 commit e51b7a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-lions-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": patch
---

fix: correctly parse platform from file URL
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 e51b7a6

Please sign in to comment.