Skip to content

Commit

Permalink
fix: altering socket will be reflected in the url
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Nov 15, 2019
1 parent 0d759d7 commit 39caadf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/service-koa.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,18 @@ export class ServiceKOA extends Service {

get url() {
const url = this.listen.url;
return url ? url : `${this.scheme}://${this.address}:${this.socket}`;

if(url) {
if(Number.isInteger(this.listen.socket)) {
const u = new URL(url);
u.port = this.socket;
return u.toString().replace(/\/$/,'');
}

return url;
}

return `${this.scheme}://${this.address}:${this.socket}`;
}

get socket() {
Expand Down
2 changes: 1 addition & 1 deletion tests/create-configure-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test(
{
adrress: address(),
socket: 1235,
// url: `http://${address()}:1235`,
url: `http://${address()}:1235`,
isSecure: false,
timeout: {
server: 123.45
Expand Down

0 comments on commit 39caadf

Please sign in to comment.