Skip to content

Commit f4ae505

Browse files
authored
feat(vscode): include host member in DartFrogApplication (#1010)
1 parent bad0f0a commit f4ae505

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

extensions/vscode/src/daemon/dart-frog-application.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
* Represents the metadata associated to a Dart Frog application.
33
*/
44
export class DartFrogApplication {
5-
constructor(projectPath: string, port: number, vmServicePort: number) {
5+
constructor(
6+
projectPath: string,
7+
port: number,
8+
vmServicePort: number,
9+
host?: string
10+
) {
611
this.projectPath = projectPath;
12+
this.host = host === undefined ? "localhost" : host;
713
this.port = port;
814
this.vmServicePort = vmServicePort;
915
}
@@ -23,6 +29,11 @@ export class DartFrogApplication {
2329
*/
2430
public readonly vmServicePort: number;
2531

32+
/**
33+
* The host on which the application is bound to.
34+
*/
35+
public readonly host: string;
36+
2637
private _id: string | undefined;
2738

2839
/**

extensions/vscode/src/status-bar/open-application-status-bar-item.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class OpenApplicationStatusBarItem extends DartFrogStatusBarItem {
3333
}
3434

3535
const application = applications[0];
36-
this.statusBarItem.text = `$(dart-frog-globe) localhost:${application.port}`;
36+
this.statusBarItem.text = `$(dart-frog-globe) ${application.host}:${application.port}`;
3737
this.statusBarItem.tooltip = "Open application in browser";
3838
const openCommand: Command = {
3939
title: "Open application in browser",

extensions/vscode/src/test/suite/daemon/dart-frog-application.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ suite("DartFrogApplication", () => {
1010
const application = new DartFrogApplication(
1111
projectPath,
1212
port,
13-
vmServicePort
13+
vmServicePort,
14+
"127.0.0.1"
1415
);
1516

1617
assert.equal(application.projectPath, projectPath);
1718
assert.equal(application.port, port);
1819
assert.equal(application.vmServicePort, vmServicePort);
20+
assert.equal(application.host, "127.0.0.1");
21+
});
22+
23+
test("host is localhost by default", () => {
24+
const application = new DartFrogApplication(
25+
projectPath,
26+
port,
27+
vmServicePort
28+
);
29+
30+
assert.equal(application.host, "localhost");
1931
});
2032

2133
suite("id", () => {

extensions/vscode/src/utils/dart-frog-application.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ export async function quickPickApplication(
5656
*/
5757
class PickableDartFrogApplication implements QuickPickItem {
5858
constructor(dartFrogApplication: DartFrogApplication) {
59-
const addressWithoutProtocol = dartFrogApplication.address!.replace(
60-
/.*?:\/\//g,
61-
""
62-
);
63-
this.label = `$(globe) ${addressWithoutProtocol}`;
59+
this.label = `$(globe) ${dartFrogApplication.host}:${dartFrogApplication.port}`;
6460
this.description = dartFrogApplication.id!.toString();
6561
this.application = dartFrogApplication;
6662
}

0 commit comments

Comments
 (0)