Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit f266970c authored by Simon Chan's avatar Simon Chan
Browse files

fix: improve regex

parent c95c63f4
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -366,8 +366,6 @@ export class PackageManager extends AdbCommandBase {
        ]);
    }

    // TODO: install: support split apk formats (`adb install-multiple`)

    static parsePackageListItem(
        line: string,
    ): PackageManagerListPackagesResult {
@@ -502,6 +500,16 @@ export class PackageManager extends AdbCommandBase {
        return output;
    }

    /**
     * Creates a new install session.
     *
     * Install sessions are used to install apps with multiple splits, but it can also be used to install a single apk.
     *
     * Install sessions was added in Android 5.0 (API level 21).
     *
     * @param options Options for the install session
     * @returns ID of the new install session
     */
    async sessionCreate(options?: Partial<PackageManagerInstallOptions>) {
        const args = this.#buildInstallArguments("install-create", options);

@@ -542,8 +550,6 @@ export class PackageManager extends AdbCommandBase {
        size: number,
        stream: ReadableStream<Consumable<Uint8Array>>,
    ) {
        // `pm install-write` supports streaming from stdin from at least Android 5
        // So assume it always works
        const args: string[] = [
            "pm",
            "install-write",
+1 −2
Original line number Diff line number Diff line
@@ -128,8 +128,7 @@ export class ScrcpyOptions1_16 implements ScrcpyOptions<ScrcpyOptionsInit1_16> {
    }

    parseDisplay(line: string): ScrcpyDisplay | undefined {
        const displayIdRegex = /\s+scrcpy --display (\d+)/;
        const match = line.match(displayIdRegex);
        const match = line.match(/^\s+scrcpy --display (\d+)$/);
        if (match) {
            return {
                id: Number.parseInt(match[1]!, 10),
+5 −3
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<

    override parseEncoder(line: string): ScrcpyEncoder | undefined {
        let match = line.match(
            /\s+--video-codec=(.*)\s+--video-encoder='(.*)'/,
            /^\s+--video-codec=(\S+)\s+--video-encoder='([^']+)'$/,
        );
        if (match) {
            return {
@@ -165,7 +165,9 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
            };
        }

        match = line.match(/\s+--audio-codec=(.*)\s+--audio-encoder='(.*)'/);
        match = line.match(
            /^\s+--audio-codec=(\S+)\s+--audio-encoder='([^']+)'$/,
        );
        if (match) {
            return {
                type: "audio",
@@ -178,7 +180,7 @@ export class ScrcpyOptions2_0 extends ScrcpyOptionsBase<
    }

    override parseDisplay(line: string): ScrcpyDisplay | undefined {
        const match = line.match(/\s+--display=(\d+)\s+\((.*?)\)/);
        const match = line.match(/^\s+--display=(\d+)\s+\(([^)]+)\)$/);
        if (match) {
            const display: ScrcpyDisplay = {
                id: Number.parseInt(match[1]!, 10),
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ export class ScrcpyOptions2_2 extends ScrcpyOptionsBase<
    }

    override parseDisplay(line: string): ScrcpyDisplay | undefined {
        const match = line.match(/\s+--display-id=(\d+)\s+\((.*?)\)/);
        const match = line.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);
        if (match) {
            const display: ScrcpyDisplay = {
                id: Number.parseInt(match[1]!, 10),