fix(core): update
This commit is contained in:
parent
48fd0516ed
commit
8762430204
1295
package-lock.json
generated
1295
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartnetwork": "^1.1.22",
|
"@pushrocks/smartnetwork": "^2.0.4",
|
||||||
"@pushrocks/smarturl": "^1.0.8"
|
"@pushrocks/smarturl": "^1.0.8"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
@ -8,7 +8,12 @@ tap.test('first test', async () => {
|
|||||||
expect(testDetector).to.be.instanceOf(detector.Detector);
|
expect(testDetector).to.be.instanceOf(detector.Detector);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should detect an open port', async () => {
|
tap.test('should detect an closed port on a local domain', async () => {
|
||||||
|
const result = await testDetector.isActive('http://localhost:3008');
|
||||||
|
expect(result).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should detect an open port on a remote domain', async () => {
|
||||||
const result = await testDetector.isActive('https://lossless.com');
|
const result = await testDetector.isActive('https://lossless.com');
|
||||||
expect(result).to.be.true;
|
expect(result).to.be.true;
|
||||||
});
|
});
|
||||||
|
@ -6,14 +6,15 @@ export class Detector {
|
|||||||
|
|
||||||
public async isActive(urlArg: string): Promise<boolean> {
|
public async isActive(urlArg: string): Promise<boolean> {
|
||||||
const parsedUrl = this.smarturlInstance.parseUrl(urlArg);
|
const parsedUrl = this.smarturlInstance.parseUrl(urlArg);
|
||||||
if (parsedUrl.host === 'localhost') {
|
if (parsedUrl.hostname === 'localhost') {
|
||||||
console.log(`detector target is localhost on port ${parsedUrl.port}`);
|
console.log(`detector target is localhost on port ${parsedUrl.port}`);
|
||||||
const result = await this.smartnetworkInstance.isLocalPortAvailable(parseInt(parsedUrl.port, 10));
|
const portUnused = await this.smartnetworkInstance.isLocalPortUnused(parseInt(parsedUrl.port, 10));
|
||||||
return result;
|
const portAvailable = !portUnused;
|
||||||
|
return portAvailable;
|
||||||
} else {
|
} else {
|
||||||
console.log(`detector target is remote domain ${parsedUrl.host} on port ${parsedUrl.port}`);
|
console.log(`detector target is remote domain ${parsedUrl.host} on port ${parsedUrl.port}`);
|
||||||
const result = await this.smartnetworkInstance.isRemotePortAvailable(parsedUrl.host, parseInt(parsedUrl.port, 10));
|
const postAvailable = await this.smartnetworkInstance.isRemotePortAvailable(parsedUrl.host, parseInt(parsedUrl.port, 10));
|
||||||
return result;
|
return postAvailable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user