Skip to content

Commit

Permalink
Add anchor tag fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Oct 9, 2024
1 parent 0c6b0a6 commit c4fc5cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,16 @@ describe('index', () => {
});

it('should return created pkg on success', async () => {
let body = `var pkgDiv = document.createElement('div');
pkgDiv.innerHTML = '<label>Currently Packaged Application:</label><div><font face="Courier"><a href="pkgs//P6953175d5df120c0069c53de12515b9a.pkg">P6953175d5df120c0069c53de12515b9a.pkg</a> <br> package file (7360 bytes)</font></div>';
node.appendChild(pkgDiv);`;
mockDoPostRequest(body);

let pkgPath = await rokuDeploy.signExistingPackage(options);
expect(pkgPath).to.equal('pkgs//P6953175d5df120c0069c53de12515b9a.pkg');
});

it('should return created pkg from SD card on success', async () => {
mockDoPostRequest(fakePluginPackageResponse);

let pkgPath = await rokuDeploy.signExistingPackage(options);
Expand Down
8 changes: 7 additions & 1 deletion src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,13 @@ export class RokuDeploy {
throw new errors.FailedDeviceResponseError(failedSearchMatches[1], results);
}

let pkgSearchMatches = /"pkgPath"\s*:\s*"([a-zA-Z0-9\\/\_]+\.pkg)"/.exec(results.body);
//grab the package url from the JSON on the page if it exists (https://regex101.com/r/1HUXgk/1)
let pkgSearchMatches = /"pkgPath"\s*:\s*"(.*?)"/.exec(results.body);
if (pkgSearchMatches) {
return pkgSearchMatches[1];
}
//for some reason we couldn't find the pkgPath from json, look in the <a> tag
pkgSearchMatches = /<a href="(pkgs\/[^\.]+\.pkg)">/.exec(results.body);
if (pkgSearchMatches) {
return pkgSearchMatches[1];
}
Expand Down

0 comments on commit c4fc5cf

Please sign in to comment.