Skip to content

Commit

Permalink
reuse activateApp in setUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
dlenroc committed Jun 12, 2024
1 parent 42f7597 commit 05d67a6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/commands/setUrl.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { errors } from '@appium/base-driver';
import type { AppId } from '@dlenroc/roku-ecp';
import { URL } from 'node:url';
import type { Driver } from '../Driver.ts';

export async function setUrl(this: Driver, url: string): Promise<void> {
const { host, pathname, searchParams } = new URL(url);
const app = pathname.slice(1) as AppId;

let params: Record<string, string> = {};
for (const [key, value] of searchParams) {
params[key] = value;
}
const app = pathname.slice(1);
const params = Object.fromEntries(searchParams);

switch (host) {
case 'launch':
return await this.sdk.ecp.launch({ appId: app, params });
return this.activateApp(app, params);
case 'input':
return await this.sdk.ecp.input(params);
return this.sdk.ecp.input(params);
default:
throw new errors.InvalidArgumentError('Unsupported URL format');
}
Expand Down

0 comments on commit 05d67a6

Please sign in to comment.