@ejfdelgado/ejflab-common 1.5.1 → 1.5.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.5.1",
4
+ "version": "1.5.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
@@ -6,9 +6,6 @@ class MyConstants {
6
6
  static NO_AUTO_PAGE_NAVITATION = ["/guides", "/assessment"];
7
7
  static CLOUD_RUN_URL = "https://mainapp-7b6hvjg6ia-uc.a.run.app/";
8
8
  static FIREBASE_CONFIG_FILE = "./credentials/firebase.pro.json";
9
- static DOMAIN_ROUTER = {
10
- "srv/opencv/solvepnp": MyConstants.CLOUD_RUN_URL
11
- };
12
9
  static ANONYMOUS_PATHS = ['/uechat', '/call', '/nogales'];
13
10
  static BUCKET = {
14
11
  URL_BASE: "https://storage.googleapis.com",
@@ -85,18 +82,11 @@ class MyConstants {
85
82
  }
86
83
  }
87
84
  static resolveDomain(path) {
88
- if (/https?:\/\//.test(path)) {
85
+ if (/^https?:\/\//i.test(path)) {
86
+ // It is a complete route
89
87
  return '';
90
88
  }
91
- if (location.hostname == "localhost") {
92
- return MyConstants.SRV_ROOT;
93
- }
94
- let domain = MyConstants.DOMAIN_ROUTER[path];
95
- if (!domain) {
96
- return MyConstants.SRV_ROOT;
97
- } else {
98
- return domain;
99
- }
89
+ return MyConstants.SRV_ROOT;
100
90
  }
101
91
  //MyConstants.getPublicUrl()
102
92
  static getPublicUrl(keyName, addRandom = true) {
@@ -144,4 +134,4 @@ try {
144
134
 
145
135
  module.exports = {
146
136
  MyConstants
147
- };
137
+ };
@@ -133,9 +133,13 @@ class MyUtilities {
133
133
 
134
134
  // MyUtilities.removeRepeatedSlash(
135
135
  static removeRepeatedSlash(url) {
136
- return url.replace(/^(https?:\/\/)(.*)$/g, (a, b, c) => {
137
- return b + c.replace(/[/]{2,}/g, '/');
138
- });
136
+ if (/^https?:/.test(url)) {
137
+ return url.replace(/^(https?:\/\/)(.*)$/g, (a, b, c) => {
138
+ return b + c.replace(/[/]{2,}/g, '/');
139
+ });
140
+ } else {
141
+ return url.replace(/[/]{2,}/g, '/');
142
+ }
139
143
  }
140
144
  }
141
145
 
package/src/changePath.js CHANGED
@@ -16,6 +16,9 @@ const FILE_PATHS = [
16
16
  "./node_modules/@ejfdelgado/ejflab-common/src/MyConstants.js",
17
17
  "./node_modules/@ejfdelgado/ejflab-back/node_modules/@ejfdelgado/ejflab-common/src/MyConstants.js"
18
18
  ];
19
+ const HTML_PATHS = [
20
+ `${DIST_DIR}/index.html`
21
+ ];
19
22
 
20
23
  // Search bundle reference
21
24
  const fileList = fs.readdirSync(DIST_DIR).filter((fileName) => {
@@ -42,4 +45,24 @@ function changeSimpleFile(filePath) {
42
45
 
43
46
  for (let i = 0; i < FILE_PATHS.length; i++) {
44
47
  changeSimpleFile(FILE_PATHS[i]);
48
+ }
49
+
50
+ // Change also the html
51
+ function changeHtmlTag(filePath) {
52
+ console.log(`Modifiying ${filePath}...`);
53
+ // Read content
54
+ if (fs.existsSync(filePath)) {
55
+ let myConstantsContent = fs.readFileSync(filePath, { encoding: "utf8" });
56
+ // Change content
57
+ myConstantsContent = myConstantsContent.replaceAll(/(<\s*base\s+href\s*=\s*")[^"]+("\s*>)/ig, `$1${NODE_SERVER_PATH}$2`);
58
+ // Write content
59
+ fs.writeFileSync(filePath, myConstantsContent, { encoding: "utf8" });
60
+ //console.log(myConstantsContent);
61
+ } else {
62
+ console.log(`Error ${filePath} dont exists! continue...`);
63
+ }
64
+ }
65
+
66
+ for (let i = 0; i < HTML_PATHS.length; i++) {
67
+ changeHtmlTag(HTML_PATHS[i]);
45
68
  }