From 731dd49309a2d7f6ad05090b33745eb2bcea49f1 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 24 Oct 2023 15:01:14 -0600 Subject: [PATCH 1/2] Calculate url on runtime --- src/app/app.module.ts | 9 +++++++++ src/environments/environment.int.ts | 4 ++-- src/environments/environment.local-with-proxy.ts | 6 ++---- src/environments/environment.local.ts | 6 ++---- src/environments/environment.production.ts | 6 ++---- src/environments/environment.qa.ts | 6 ++---- src/environments/environment.sandbox.ts | 6 ++---- src/environments/subdomain.adapter.ts | 4 ---- 8 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 src/environments/subdomain.adapter.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ece0ffd47e..fb45f6b2fe 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -44,10 +44,19 @@ export class AppModule { private initializeApp() { environment.BASE_URL = this.getCurrentDomain() + environment.API_WEB = environment.API_WEB.replace( + '', + this.getSubDomain() + ) } getCurrentDomain() { const port = window.location.port ? ':' + window.location.port : '' return '//' + window.location.hostname + port + '/' } + + getSubDomain() { + const subdomain = window.location.hostname.split('.').slice(0, -2).join('.') + return subdomain ? subdomain + '.' : '' + } } diff --git a/src/environments/environment.int.ts b/src/environments/environment.int.ts index c29298cefd..0da1a008e7 100644 --- a/src/environments/environment.int.ts +++ b/src/environments/environment.int.ts @@ -5,8 +5,8 @@ export const environment = { debugger: true, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.int.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, + API_PUB: `//pub.orcid.org/v3.0`, + API_WEB: `//orcid.org/`, BASE_URL: '', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, diff --git a/src/environments/environment.local-with-proxy.ts b/src/environments/environment.local-with-proxy.ts index bfcf39d179..1475d7062b 100644 --- a/src/environments/environment.local-with-proxy.ts +++ b/src/environments/environment.local-with-proxy.ts @@ -1,12 +1,10 @@ -import { getSubDomain } from "./subdomain.adapter"; - export const environment = { production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: `//${getSubDomain()}localhost:4200/v3.0`, - API_WEB: `//${getSubDomain()}localhost:4200/`, + API_PUB: `//localhost:4200/v3.0`, + API_WEB: `//localhost:4200/`, BASE_URL: '', INFO_SITE: 'https://info.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index 17a2c48d44..238734638a 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -1,12 +1,10 @@ -import { getSubDomain } from "./subdomain.adapter"; - export const environment = { production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, + API_PUB: `//pub.orcid.org/v3.0`, + API_WEB: `//orcid.org/`, BASE_URL: '', INFO_SITE: 'https://info.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, diff --git a/src/environments/environment.production.ts b/src/environments/environment.production.ts index 875cc1bcb6..aabd4682cb 100644 --- a/src/environments/environment.production.ts +++ b/src/environments/environment.production.ts @@ -1,12 +1,10 @@ -import { getSubDomain } from "./subdomain.adapter"; - export const environment = { production: true, debugger: false, ROBOTS: 'all', API_NEWS: 'https://info.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, + API_PUB: `//pub.orcid.org/v3.0`, + API_WEB: `//orcid.org/`, BASE_URL: '', INFO_SITE: 'https://info.orcid.org/', SHOW_TEST_WARNING_BANNER: false, diff --git a/src/environments/environment.qa.ts b/src/environments/environment.qa.ts index 738924ed73..3cfb8762b8 100644 --- a/src/environments/environment.qa.ts +++ b/src/environments/environment.qa.ts @@ -1,12 +1,10 @@ -import { getSubDomain } from "./subdomain.adapter"; - export const environment = { production: true, debugger: true, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, + API_PUB: `//pub.orcid.org/v3.0`, + API_WEB: `//orcid.org/`, BASE_URL: '', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, diff --git a/src/environments/environment.sandbox.ts b/src/environments/environment.sandbox.ts index 209db30d39..c82224ebda 100644 --- a/src/environments/environment.sandbox.ts +++ b/src/environments/environment.sandbox.ts @@ -1,12 +1,10 @@ -import { getSubDomain } from "./subdomain.adapter"; - export const environment = { production: true, debugger: false, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, + API_PUB: `//pub.orcid.org/v3.0`, + API_WEB: `//orcid.org/`, BASE_URL: '', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: false, diff --git a/src/environments/subdomain.adapter.ts b/src/environments/subdomain.adapter.ts deleted file mode 100644 index 6dac065eee..0000000000 --- a/src/environments/subdomain.adapter.ts +++ /dev/null @@ -1,4 +0,0 @@ -export function getSubDomain() { - const subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); - return subdomain? subdomain+'.':'' -} From be63032b04dfb79624997a1db379460c35ab76b3 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 24 Oct 2023 15:18:32 -0600 Subject: [PATCH 2/2] calculate all domains and subdomains on runtime: --- src/app/app.module.ts | 17 ++++++++++++++--- src/app/cdk/platform-info/browserlist.regexp.ts | 3 ++- src/environments/environment.int.ts | 2 +- .../environment.local-with-proxy.ts | 6 +++--- src/environments/environment.local.ts | 6 +++--- src/environments/environment.production.ts | 8 +++----- src/environments/environment.qa.ts | 6 +++--- src/environments/environment.sandbox.ts | 6 +++--- 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index fb45f6b2fe..47c6467d23 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -43,16 +43,27 @@ export class AppModule { } private initializeApp() { - environment.BASE_URL = this.getCurrentDomain() environment.API_WEB = environment.API_WEB.replace( '', this.getSubDomain() ) + environment.BASE_URL = environment.BASE_URL.replace( + '', + this.getSubDomain() + ) + environment.API_WEB = environment.API_WEB.replace( + '', + this.getCurrentLeanDomain() + ) + environment.BASE_URL = environment.BASE_URL.replace( + '', + this.getCurrentLeanDomain() + ) } - getCurrentDomain() { + getCurrentLeanDomain() { const port = window.location.port ? ':' + window.location.port : '' - return '//' + window.location.hostname + port + '/' + return window.location.hostname.split('.').slice(-2).join('.') + port } getSubDomain() { diff --git a/src/app/cdk/platform-info/browserlist.regexp.ts b/src/app/cdk/platform-info/browserlist.regexp.ts index 954be17405..dd011b22dc 100644 --- a/src/app/cdk/platform-info/browserlist.regexp.ts +++ b/src/app/cdk/platform-info/browserlist.regexp.ts @@ -1,2 +1,3 @@ // tslint:disable-next-line: max-line-length -export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ +export const BROWSERLIST_REGEXP = + /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ diff --git a/src/environments/environment.int.ts b/src/environments/environment.int.ts index 0da1a008e7..0116e1659e 100644 --- a/src/environments/environment.int.ts +++ b/src/environments/environment.int.ts @@ -1,4 +1,4 @@ -import { getSubDomain } from "./subdomain.adapter"; +import { getSubDomain } from './subdomain.adapter' export const environment = { production: true, diff --git a/src/environments/environment.local-with-proxy.ts b/src/environments/environment.local-with-proxy.ts index 1475d7062b..ffa66255b3 100644 --- a/src/environments/environment.local-with-proxy.ts +++ b/src/environments/environment.local-with-proxy.ts @@ -3,9 +3,9 @@ export const environment = { debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: `//localhost:4200/v3.0`, - API_WEB: `//localhost:4200/`, - BASE_URL: '', + API_PUB: `///v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-0000000', diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index 238734638a..5941c79dcd 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -3,9 +3,9 @@ export const environment = { debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: `//pub.orcid.org/v3.0`, - API_WEB: `//orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-0000000', diff --git a/src/environments/environment.production.ts b/src/environments/environment.production.ts index aabd4682cb..09eae28d28 100644 --- a/src/environments/environment.production.ts +++ b/src/environments/environment.production.ts @@ -3,9 +3,9 @@ export const environment = { debugger: false, ROBOTS: 'all', API_NEWS: 'https://info.orcid.org/feed/', - API_PUB: `//pub.orcid.org/v3.0`, - API_WEB: `//orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.orcid.org/', SHOW_TEST_WARNING_BANNER: false, GOOGLE_ANALYTICS_TESTING_MODE: false, @@ -34,5 +34,3 @@ export const environment = { }, proxyMode: false, } - - diff --git a/src/environments/environment.qa.ts b/src/environments/environment.qa.ts index 3cfb8762b8..e3e754aaca 100644 --- a/src/environments/environment.qa.ts +++ b/src/environments/environment.qa.ts @@ -3,9 +3,9 @@ export const environment = { debugger: true, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: `//pub.orcid.org/v3.0`, - API_WEB: `//orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-TRLHLRZ', diff --git a/src/environments/environment.sandbox.ts b/src/environments/environment.sandbox.ts index c82224ebda..40106352b1 100644 --- a/src/environments/environment.sandbox.ts +++ b/src/environments/environment.sandbox.ts @@ -3,9 +3,9 @@ export const environment = { debugger: false, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: `//pub.orcid.org/v3.0`, - API_WEB: `//orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: false, GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS',