@yolo-croket-dev/core 1.9.7 → 1.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/util.js +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",
package/util.js CHANGED
@@ -10,8 +10,13 @@ function generateRandom(length, charset) {
10
10
  }
11
11
  exports.generateRandom = generateRandom;
12
12
  /** host에서 port를 추출합니다. */
13
+ // ex) dns://user-service.croket.svc.cluster.local:50051 => 50051
14
+ // ex) localhost:50051 => 50051
13
15
  function getPortFromHost(host) {
14
- const port = host.split(':')[1];
15
- return port ? parseInt(port, 10) : undefined;
16
+ const specificHost = host.includes('://') ? host.split('://')[1] : host;
17
+ if (specificHost.includes(':' && specificHost.split(':')[1])) {
18
+ return parseInt(specificHost.split(':')[1], 10);
19
+ }
20
+ return undefined;
16
21
  }
17
22
  exports.getPortFromHost = getPortFromHost;