Skip to content

Commit

Permalink
Fix stopOnEntry bug with deep links.
Browse files Browse the repository at this point in the history
Fix dns resolving for deep links
  • Loading branch information
TwitchBronBron committed Aug 19, 2022
1 parent 8113fa4 commit e45e39c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,11 @@ export class BrightScriptDebugSession extends BaseDebugSession {
await this.rokuAdapter.continue();
//kill the app on the roku
await this.rokuDeploy.pressHomeButton(this.launchConfiguration.host, this.launchConfiguration.remotePort);
//convert a hostname to an ip address
const deepLinkUrl = await util.resolveUrl(this.launchConfiguration.deepLinkUrl);
//send the deep link http request
await new Promise((resolve, reject) => {
request.post(this.launchConfiguration.deepLinkUrl, (err, response) => {
request.post(deepLinkUrl, (err, response) => {
return err ? reject(err) : resolve(response);
});
});
Expand Down Expand Up @@ -1184,7 +1186,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
public async handleEntryBreakpoint() {
if (!this.enableDebugProtocol) {
this.entryBreakpointWasHandled = true;
if (this.launchConfiguration.stopOnEntry) {
if (this.launchConfiguration.stopOnEntry || this.launchConfiguration.deepLinkUrl) {
await this.projectManager.registerEntryBreakpoint(this.projectManager.mainProject.stagingFolderPath);
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,19 @@ class Util {
}
}

/**
* Given a full URL, convert any dns name into its IP address and then return the full URL with the name replaced
*/
public async resolveUrl(url: string, skipCache = false) {
//https://regex101.com/r/cSkoTx/1
const [, protocol, host] = /^((?:http[s]?|ftp):\/\/)?([^:\/\s]+)(:\d+)?([^?#]+)?(\?[^#]+)?(#.*)?$/.exec(url) ?? [];
if (host) {
const ipAddress = await this.dnsLookup(host);
url = protocol + ipAddress + url.substring(protocol.length + host.length);
}
return url;
}

/*
* Look up the ip address for a hostname. This is cached for the lifetime of the app, or bypassed with the `skipCache` parameter
* @param host
Expand Down

0 comments on commit e45e39c

Please sign in to comment.