@postnord/pn-marketweb-components 2.3.0 → 2.3.1
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/cjs/{MarketWebContextService-392b4585.js → MarketWebContextService-f77b4a5f.js} +61 -59
- package/cjs/pn-language-selector_9.cjs.entry.js +22 -13
- package/cjs/pn-marketweb-sitefooter.cjs.entry.js +1 -1
- package/cjs/pn-marketweb-siteheader.cjs.entry.js +1 -1
- package/cjs/pn-proxio-findprice.cjs.entry.js +1 -1
- package/cjs/pn-proxio-pricegroup.cjs.entry.js +1 -1
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js +3 -2
- package/collection/components/navigation/pn-language-selector/translations.js +22 -13
- package/collection/globals/MarketWebContextService.js +61 -59
- package/custom-elements/index.js +83 -72
- package/esm/{MarketWebContextService-872043cc.js → MarketWebContextService-3ed3fe80.js} +61 -59
- package/esm/pn-language-selector_9.entry.js +22 -13
- package/esm/pn-marketweb-sitefooter.entry.js +1 -1
- package/esm/pn-marketweb-siteheader.entry.js +1 -1
- package/esm/pn-proxio-findprice.entry.js +1 -1
- package/esm/pn-proxio-pricegroup.entry.js +1 -1
- package/esm-es5/MarketWebContextService-3ed3fe80.js +1 -0
- package/esm-es5/pn-language-selector_9.entry.js +1 -1
- package/esm-es5/pn-marketweb-sitefooter.entry.js +1 -1
- package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
- package/esm-es5/pn-proxio-findprice.entry.js +1 -1
- package/esm-es5/pn-proxio-pricegroup.entry.js +1 -1
- package/package.json +1 -1
- package/pn-market-web-components/{p-5176eaf3.entry.js → p-30d3dc6f.entry.js} +1 -1
- package/pn-market-web-components/p-67887512.system.js +1 -1
- package/pn-market-web-components/{p-befd7c8d.entry.js → p-77c907d9.entry.js} +1 -1
- package/pn-market-web-components/p-783b4892.js +1 -0
- package/pn-market-web-components/{p-dc714241.entry.js → p-803088a3.entry.js} +1 -1
- package/pn-market-web-components/p-861def61.entry.js +1 -0
- package/pn-market-web-components/p-8f1b7c70.system.entry.js +1 -0
- package/pn-market-web-components/{p-fe417bbb.system.entry.js → p-906719be.system.entry.js} +1 -1
- package/pn-market-web-components/{p-dd0b02de.entry.js → p-9c2c1aa2.entry.js} +1 -1
- package/pn-market-web-components/p-cb53b67f.system.js +1 -0
- package/pn-market-web-components/{p-9c18464d.system.entry.js → p-efe598a8.system.entry.js} +1 -1
- package/pn-market-web-components/{p-ed990629.system.entry.js → p-f008015e.system.entry.js} +1 -1
- package/pn-market-web-components/{p-5b802a17.system.entry.js → p-f583fba4.system.entry.js} +1 -1
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/navigation/pn-language-selector/translations.d.ts +9 -0
- package/esm-es5/MarketWebContextService-872043cc.js +0 -1
- package/pn-market-web-components/p-31fd7a95.system.js +0 -1
- package/pn-market-web-components/p-74120b9b.js +0 -1
- package/pn-market-web-components/p-84193b02.system.entry.js +0 -1
- package/pn-market-web-components/p-b3bf353f.entry.js +0 -1
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
class MarketWebContextService {
|
|
2
2
|
constructor(href = window.location.href) {
|
|
3
|
-
this.href =
|
|
4
|
-
this.market =
|
|
5
|
-
this.language =
|
|
6
|
-
this.environment =
|
|
3
|
+
this.href = '';
|
|
4
|
+
this.market = '';
|
|
5
|
+
this.language = '';
|
|
6
|
+
this.environment = '';
|
|
7
7
|
this.url = null;
|
|
8
|
-
this.allowedLanguages = [
|
|
9
|
-
this.allowedMarkets = [
|
|
10
|
-
this.wwwMarkets = [
|
|
11
|
-
this.developmentDomains = [
|
|
8
|
+
this.allowedLanguages = ['sv', 'da', 'fi', 'no', 'en', 'de', 'zh', 'fr', 'es'];
|
|
9
|
+
this.allowedMarkets = ['se', 'dk', 'fi', 'no', 'com', 'de', 'tpl'];
|
|
10
|
+
this.wwwMarkets = ['se', 'dk', 'fi', 'no', 'de', 'com'];
|
|
11
|
+
this.developmentDomains = ['localhost', '.local', 'local.', '.dev', 'dev.'];
|
|
12
12
|
this.markets = {
|
|
13
|
-
|
|
14
|
-
fallbackLanguage:
|
|
13
|
+
se: {
|
|
14
|
+
fallbackLanguage: 'sv',
|
|
15
15
|
integration: 'se-integration.postnord.com',
|
|
16
16
|
preproduction: 'se-preproduction.postnord.com',
|
|
17
17
|
production: 'se-production.postnord.com',
|
|
18
|
-
live: 'www.postnord.se'
|
|
18
|
+
live: 'www.postnord.se',
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
fallbackLanguage:
|
|
20
|
+
dk: {
|
|
21
|
+
fallbackLanguage: 'da',
|
|
22
22
|
integration: 'dk-integration.postnord.com',
|
|
23
23
|
preproduction: 'dk-preproduction.postnord.com',
|
|
24
24
|
production: 'dk-production.postnord.com',
|
|
25
|
-
live: 'www.postnord.dk'
|
|
25
|
+
live: 'www.postnord.dk',
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
fallbackLanguage:
|
|
27
|
+
fi: {
|
|
28
|
+
fallbackLanguage: 'fi',
|
|
29
29
|
integration: 'fi-integration.postnord.com',
|
|
30
30
|
preproduction: 'fi-preproduction.postnord.com',
|
|
31
31
|
production: 'fi-production.postnord.com',
|
|
32
|
-
live: 'www.postnord.fi'
|
|
32
|
+
live: 'www.postnord.fi',
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
fallbackLanguage:
|
|
34
|
+
no: {
|
|
35
|
+
fallbackLanguage: 'no',
|
|
36
36
|
integration: 'no-integration.postnord.com',
|
|
37
37
|
preproduction: 'no-preproduction.postnord.com',
|
|
38
38
|
production: 'no-production.postnord.com',
|
|
39
|
-
live: 'www.postnord.no'
|
|
39
|
+
live: 'www.postnord.no',
|
|
40
40
|
},
|
|
41
|
-
|
|
42
|
-
fallbackLanguage:
|
|
41
|
+
com: {
|
|
42
|
+
fallbackLanguage: 'en',
|
|
43
43
|
integration: 'com-integration.postnord.com',
|
|
44
44
|
preproduction: 'com-preproduction.postnord.com',
|
|
45
45
|
production: 'com-production.postnord.com',
|
|
46
|
-
live: 'www.postnord.com'
|
|
46
|
+
live: 'www.postnord.com',
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
fallbackLanguage:
|
|
48
|
+
de: {
|
|
49
|
+
fallbackLanguage: 'en',
|
|
50
50
|
integration: 'de-integration.postnord.com',
|
|
51
51
|
preproduction: 'de-preproduction.postnord.com',
|
|
52
52
|
production: 'de-production.postnord.com',
|
|
53
|
-
live: 'www.postnord.de'
|
|
53
|
+
live: 'www.postnord.de',
|
|
54
54
|
},
|
|
55
|
-
|
|
56
|
-
fallbackLanguage:
|
|
55
|
+
tpl: {
|
|
56
|
+
fallbackLanguage: 'sv',
|
|
57
57
|
integration: 'tpl-integration.postnord.com',
|
|
58
58
|
preproduction: 'tpl-preproduction.postnord.com',
|
|
59
59
|
production: 'tpl-production.postnord.com',
|
|
60
|
-
live: 'tpl.postnord.com'
|
|
60
|
+
live: 'tpl.postnord.com',
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
|
-
this.environmentTypes = [
|
|
63
|
+
this.environmentTypes = ['integration', 'preproduction', 'production'];
|
|
64
64
|
this.environments = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
production: {
|
|
66
|
+
name: 'production',
|
|
67
|
+
url: 'https://www.postnord.xx/',
|
|
68
68
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
preproduction: {
|
|
70
|
+
name: 'preproduction',
|
|
71
|
+
url: 'https://com-preproduction.postnord.com/',
|
|
72
|
+
},
|
|
73
|
+
integration: {
|
|
74
|
+
name: 'integration',
|
|
75
|
+
url: 'https://com-integration.postnord.com/',
|
|
72
76
|
},
|
|
73
|
-
"integration": {
|
|
74
|
-
"name": "integration",
|
|
75
|
-
"url": "https://com-integration.postnord.com/"
|
|
76
|
-
}
|
|
77
77
|
};
|
|
78
78
|
this.href = href;
|
|
79
79
|
this.url = new URL(this.href);
|
|
@@ -92,7 +92,7 @@ class MarketWebContextService {
|
|
|
92
92
|
await this.resolveMarket();
|
|
93
93
|
return this.market;
|
|
94
94
|
}
|
|
95
|
-
async getEndpoint(environmentName, marketName =
|
|
95
|
+
async getEndpoint(environmentName, marketName = '') {
|
|
96
96
|
let url = this.environments.production.url;
|
|
97
97
|
if (this.markets[marketName] && this.markets[marketName][environmentName]) {
|
|
98
98
|
if (environmentName === 'production' && window.location.hostname.indexOf(this.markets[marketName]['live']) === 0) {
|
|
@@ -109,18 +109,18 @@ class MarketWebContextService {
|
|
|
109
109
|
if (environmentName === this.environments.production.name) {
|
|
110
110
|
if (this.wwwMarkets.indexOf(marketName) !== -1) {
|
|
111
111
|
// Handles www.postnord.xx domains
|
|
112
|
-
url = url.replace(
|
|
112
|
+
url = url.replace('.xx', '.' + marketName);
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
url = url.replace(
|
|
116
|
-
url = url.replace(
|
|
115
|
+
url = url.replace('.xx', '.com'); // Expect URL to end in postnord.com
|
|
116
|
+
url = url.replace('www.', marketName + '.');
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
return url;
|
|
121
121
|
}
|
|
122
122
|
async getEnvironmentName() {
|
|
123
|
-
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf(
|
|
123
|
+
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf('-' + x) !== -1)[0];
|
|
124
124
|
if (likelyEnvironment) {
|
|
125
125
|
this.environment = likelyEnvironment;
|
|
126
126
|
return this.environment;
|
|
@@ -138,17 +138,17 @@ class MarketWebContextService {
|
|
|
138
138
|
}
|
|
139
139
|
async resolveMarket() {
|
|
140
140
|
// Resolve market from www domains
|
|
141
|
-
if (this.href.indexOf(
|
|
141
|
+
if (this.href.indexOf('//www.') !== -1) {
|
|
142
142
|
const domainRoot = this.url.hostname.substring(this.url.hostname.lastIndexOf('.') + 1, this.url.hostname.length);
|
|
143
143
|
if (domainRoot && this.markets[domainRoot]) {
|
|
144
144
|
this.market = domainRoot;
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
|
-
console.warn(
|
|
147
|
+
console.warn('Unable to define market from www. domain', this.href);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
// Check if domains are on one of the integration/preproduction/production environments urls
|
|
151
|
-
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf(
|
|
151
|
+
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf('-' + x) !== -1);
|
|
152
152
|
if (!this.market && likelyEnvironment && likelyEnvironment.length > 0) {
|
|
153
153
|
const matchedEnvironment = likelyEnvironment[0];
|
|
154
154
|
const marketPrefix = this.url.hostname.substring(0, this.url.hostname.indexOf('-' + matchedEnvironment));
|
|
@@ -156,14 +156,14 @@ class MarketWebContextService {
|
|
|
156
156
|
this.market = marketPrefix;
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
|
-
console.warn(
|
|
159
|
+
console.warn('Unable to define market from preset environment names', this.href);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
if (!this.market) {
|
|
163
163
|
if (this.url.hostname.indexOf('www') === -1 && this.url.hostname.indexOf('.postnord.') > 0) {
|
|
164
164
|
const start = this.url.hostname.indexOf('.') !== this.url.hostname.indexOf('.postnord') ? this.url.hostname.indexOf('.') : 0;
|
|
165
165
|
const potentialMarket = this.url.hostname.substring(start, this.url.hostname.indexOf('.postnord.'));
|
|
166
|
-
// Break down the subdomain to the word closest to .postnord. and take that word.
|
|
166
|
+
// Break down the subdomain to the word closest to .postnord. and take that word.
|
|
167
167
|
// Supports sub-sub domain down to 1 level.
|
|
168
168
|
if (this.allowedMarkets.indexOf(potentialMarket) !== -1) {
|
|
169
169
|
this.market = potentialMarket;
|
|
@@ -171,7 +171,7 @@ class MarketWebContextService {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
// Check if we're on a development environment
|
|
174
|
+
// Check if we're on a development environment
|
|
175
175
|
if (!this.market) {
|
|
176
176
|
const matchedDevEnvironment = this.developmentDomains.filter(x => this.url.hostname.indexOf(x) !== -1)[0];
|
|
177
177
|
if (!matchedDevEnvironment) {
|
|
@@ -179,7 +179,7 @@ class MarketWebContextService {
|
|
|
179
179
|
this.market = this.allowedMarkets[0];
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
|
-
const urlWithoutDomain = this.href.replace(matchedDevEnvironment,
|
|
182
|
+
const urlWithoutDomain = this.href.replace(matchedDevEnvironment, '');
|
|
183
183
|
// We see if the dev environment contains something like /dk
|
|
184
184
|
let matchedMarket = this.allowedMarkets.filter(x => {
|
|
185
185
|
const typesOfFallback = ['.' + x, x + '.', '/' + x + '/']; // Ex /dk, dk.html, /dk/
|
|
@@ -191,7 +191,7 @@ class MarketWebContextService {
|
|
|
191
191
|
}
|
|
192
192
|
else {
|
|
193
193
|
// We do a similar filter for subpaths but for language this time
|
|
194
|
-
let filteredMarket = Object.entries(this.markets).filter(
|
|
194
|
+
let filteredMarket = Object.entries(this.markets).filter(item => {
|
|
195
195
|
const typesOfFallback = ['.' + item[1].fallbackLanguage, item[1].fallbackLanguage + '.', '/' + item[1].fallbackLanguage + '/']; // Ex /dk, dk.html, /dk/
|
|
196
196
|
const matchedTypeOfFallback = typesOfFallback.filter(y => urlWithoutDomain.indexOf(y) !== -1);
|
|
197
197
|
return matchedTypeOfFallback.length > 0;
|
|
@@ -202,7 +202,7 @@ class MarketWebContextService {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
if (!this.market) {
|
|
205
|
-
console.info(
|
|
205
|
+
console.info('Was unable to detect market, used fallback');
|
|
206
206
|
this.market = this.allowedMarkets[0];
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -212,12 +212,14 @@ class MarketWebContextService {
|
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
const potentialLanguages = [
|
|
215
|
-
(_a = document.querySelector(
|
|
216
|
-
(_b = document.querySelector('[http-equiv="content-language"][content]')) === null || _b === void 0 ? void 0 : _b.getAttribute(
|
|
217
|
-
(_c = document.querySelector('[property="og:locale"][content]')) === null || _c === void 0 ? void 0 : _c.getAttribute(
|
|
218
|
-
(_d = document.querySelector(
|
|
215
|
+
(_a = document.querySelector('html[lang]')) === null || _a === void 0 ? void 0 : _a.getAttribute('lang'),
|
|
216
|
+
(_b = document.querySelector('[http-equiv="content-language"][content]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content'),
|
|
217
|
+
(_c = document.querySelector('[property="og:locale"][content]')) === null || _c === void 0 ? void 0 : _c.getAttribute('content'),
|
|
218
|
+
(_d = document.querySelector('[lang]')) === null || _d === void 0 ? void 0 : _d.getAttribute('lang'),
|
|
219
219
|
];
|
|
220
|
-
potentialLanguages
|
|
220
|
+
potentialLanguages
|
|
221
|
+
.filter(x => x)
|
|
222
|
+
.forEach(language => {
|
|
221
223
|
if (this.allowedLanguages.indexOf(language)) {
|
|
222
224
|
this.language = language;
|
|
223
225
|
return;
|
package/custom-elements/index.js
CHANGED
|
@@ -25150,24 +25150,33 @@ let PnfindServiceAndPriceResult = class extends HTMLElement {
|
|
|
25150
25150
|
};
|
|
25151
25151
|
|
|
25152
25152
|
const translations$a = {
|
|
25153
|
-
|
|
25154
|
-
|
|
25153
|
+
sv: {
|
|
25154
|
+
heading: 'Språk',
|
|
25155
25155
|
},
|
|
25156
|
-
|
|
25157
|
-
|
|
25156
|
+
en: {
|
|
25157
|
+
heading: 'Language',
|
|
25158
25158
|
},
|
|
25159
|
-
|
|
25160
|
-
|
|
25159
|
+
da: {
|
|
25160
|
+
heading: 'Sprog',
|
|
25161
25161
|
},
|
|
25162
|
-
|
|
25163
|
-
|
|
25162
|
+
no: {
|
|
25163
|
+
heading: 'Språk',
|
|
25164
25164
|
},
|
|
25165
|
-
|
|
25166
|
-
|
|
25165
|
+
fi: {
|
|
25166
|
+
heading: 'Kieli',
|
|
25167
|
+
},
|
|
25168
|
+
de: {
|
|
25169
|
+
heading: 'Sprache',
|
|
25170
|
+
},
|
|
25171
|
+
zh: {
|
|
25172
|
+
heading: '语言',
|
|
25173
|
+
},
|
|
25174
|
+
fr: {
|
|
25175
|
+
heading: 'Langue',
|
|
25176
|
+
},
|
|
25177
|
+
es: {
|
|
25178
|
+
heading: 'Idioma',
|
|
25167
25179
|
},
|
|
25168
|
-
'de': {
|
|
25169
|
-
"heading": "Sprache"
|
|
25170
|
-
}
|
|
25171
25180
|
};
|
|
25172
25181
|
|
|
25173
25182
|
const pnLanguageSelectorCss = "pn-language-selector{max-height:5.2rem}pn-language-selector pn-nav-dropdown:not([data-open]) .nav-dropdown-content-container,pn-language-selector pn-nav-dropdown[data-open=false] .nav-dropdown-content-container{display:none}pn-language-selector pn-nav-dropdown{display:block}.languageselector{position:relative}.languageselector-togglebtn{cursor:pointer;border:0;padding:0.64rem 0;background-color:#FFFFFF;color:#005D92;font-size:1.6rem}.languageselector-togglebtn:hover,.languageselector-togglebtn:focus,.languageselector-togglebtn:active{color:#0D234B;text-decoration:underline}.languageselector-togglebtn svg{width:1.9rem;height:1.9rem}.languageselector-title{padding:0.8rem 1.6rem;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.languageselector-list{margin:0;padding:0;list-style:none}";
|
|
@@ -25811,80 +25820,80 @@ class FetchHelper {
|
|
|
25811
25820
|
|
|
25812
25821
|
class MarketWebContextService {
|
|
25813
25822
|
constructor(href = window.location.href) {
|
|
25814
|
-
this.href =
|
|
25815
|
-
this.market =
|
|
25816
|
-
this.language =
|
|
25817
|
-
this.environment =
|
|
25823
|
+
this.href = '';
|
|
25824
|
+
this.market = '';
|
|
25825
|
+
this.language = '';
|
|
25826
|
+
this.environment = '';
|
|
25818
25827
|
this.url = null;
|
|
25819
|
-
this.allowedLanguages = [
|
|
25820
|
-
this.allowedMarkets = [
|
|
25821
|
-
this.wwwMarkets = [
|
|
25822
|
-
this.developmentDomains = [
|
|
25828
|
+
this.allowedLanguages = ['sv', 'da', 'fi', 'no', 'en', 'de', 'zh', 'fr', 'es'];
|
|
25829
|
+
this.allowedMarkets = ['se', 'dk', 'fi', 'no', 'com', 'de', 'tpl'];
|
|
25830
|
+
this.wwwMarkets = ['se', 'dk', 'fi', 'no', 'de', 'com'];
|
|
25831
|
+
this.developmentDomains = ['localhost', '.local', 'local.', '.dev', 'dev.'];
|
|
25823
25832
|
this.markets = {
|
|
25824
|
-
|
|
25825
|
-
fallbackLanguage:
|
|
25833
|
+
se: {
|
|
25834
|
+
fallbackLanguage: 'sv',
|
|
25826
25835
|
integration: 'se-integration.postnord.com',
|
|
25827
25836
|
preproduction: 'se-preproduction.postnord.com',
|
|
25828
25837
|
production: 'se-production.postnord.com',
|
|
25829
|
-
live: 'www.postnord.se'
|
|
25838
|
+
live: 'www.postnord.se',
|
|
25830
25839
|
},
|
|
25831
|
-
|
|
25832
|
-
fallbackLanguage:
|
|
25840
|
+
dk: {
|
|
25841
|
+
fallbackLanguage: 'da',
|
|
25833
25842
|
integration: 'dk-integration.postnord.com',
|
|
25834
25843
|
preproduction: 'dk-preproduction.postnord.com',
|
|
25835
25844
|
production: 'dk-production.postnord.com',
|
|
25836
|
-
live: 'www.postnord.dk'
|
|
25845
|
+
live: 'www.postnord.dk',
|
|
25837
25846
|
},
|
|
25838
|
-
|
|
25839
|
-
fallbackLanguage:
|
|
25847
|
+
fi: {
|
|
25848
|
+
fallbackLanguage: 'fi',
|
|
25840
25849
|
integration: 'fi-integration.postnord.com',
|
|
25841
25850
|
preproduction: 'fi-preproduction.postnord.com',
|
|
25842
25851
|
production: 'fi-production.postnord.com',
|
|
25843
|
-
live: 'www.postnord.fi'
|
|
25852
|
+
live: 'www.postnord.fi',
|
|
25844
25853
|
},
|
|
25845
|
-
|
|
25846
|
-
fallbackLanguage:
|
|
25854
|
+
no: {
|
|
25855
|
+
fallbackLanguage: 'no',
|
|
25847
25856
|
integration: 'no-integration.postnord.com',
|
|
25848
25857
|
preproduction: 'no-preproduction.postnord.com',
|
|
25849
25858
|
production: 'no-production.postnord.com',
|
|
25850
|
-
live: 'www.postnord.no'
|
|
25859
|
+
live: 'www.postnord.no',
|
|
25851
25860
|
},
|
|
25852
|
-
|
|
25853
|
-
fallbackLanguage:
|
|
25861
|
+
com: {
|
|
25862
|
+
fallbackLanguage: 'en',
|
|
25854
25863
|
integration: 'com-integration.postnord.com',
|
|
25855
25864
|
preproduction: 'com-preproduction.postnord.com',
|
|
25856
25865
|
production: 'com-production.postnord.com',
|
|
25857
|
-
live: 'www.postnord.com'
|
|
25866
|
+
live: 'www.postnord.com',
|
|
25858
25867
|
},
|
|
25859
|
-
|
|
25860
|
-
fallbackLanguage:
|
|
25868
|
+
de: {
|
|
25869
|
+
fallbackLanguage: 'en',
|
|
25861
25870
|
integration: 'de-integration.postnord.com',
|
|
25862
25871
|
preproduction: 'de-preproduction.postnord.com',
|
|
25863
25872
|
production: 'de-production.postnord.com',
|
|
25864
|
-
live: 'www.postnord.de'
|
|
25873
|
+
live: 'www.postnord.de',
|
|
25865
25874
|
},
|
|
25866
|
-
|
|
25867
|
-
fallbackLanguage:
|
|
25875
|
+
tpl: {
|
|
25876
|
+
fallbackLanguage: 'sv',
|
|
25868
25877
|
integration: 'tpl-integration.postnord.com',
|
|
25869
25878
|
preproduction: 'tpl-preproduction.postnord.com',
|
|
25870
25879
|
production: 'tpl-production.postnord.com',
|
|
25871
|
-
live: 'tpl.postnord.com'
|
|
25880
|
+
live: 'tpl.postnord.com',
|
|
25872
25881
|
},
|
|
25873
25882
|
};
|
|
25874
|
-
this.environmentTypes = [
|
|
25883
|
+
this.environmentTypes = ['integration', 'preproduction', 'production'];
|
|
25875
25884
|
this.environments = {
|
|
25876
|
-
|
|
25877
|
-
|
|
25878
|
-
|
|
25885
|
+
production: {
|
|
25886
|
+
name: 'production',
|
|
25887
|
+
url: 'https://www.postnord.xx/',
|
|
25879
25888
|
},
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25889
|
+
preproduction: {
|
|
25890
|
+
name: 'preproduction',
|
|
25891
|
+
url: 'https://com-preproduction.postnord.com/',
|
|
25892
|
+
},
|
|
25893
|
+
integration: {
|
|
25894
|
+
name: 'integration',
|
|
25895
|
+
url: 'https://com-integration.postnord.com/',
|
|
25883
25896
|
},
|
|
25884
|
-
"integration": {
|
|
25885
|
-
"name": "integration",
|
|
25886
|
-
"url": "https://com-integration.postnord.com/"
|
|
25887
|
-
}
|
|
25888
25897
|
};
|
|
25889
25898
|
this.href = href;
|
|
25890
25899
|
this.url = new URL(this.href);
|
|
@@ -25903,7 +25912,7 @@ class MarketWebContextService {
|
|
|
25903
25912
|
await this.resolveMarket();
|
|
25904
25913
|
return this.market;
|
|
25905
25914
|
}
|
|
25906
|
-
async getEndpoint(environmentName, marketName =
|
|
25915
|
+
async getEndpoint(environmentName, marketName = '') {
|
|
25907
25916
|
let url = this.environments.production.url;
|
|
25908
25917
|
if (this.markets[marketName] && this.markets[marketName][environmentName]) {
|
|
25909
25918
|
if (environmentName === 'production' && window.location.hostname.indexOf(this.markets[marketName]['live']) === 0) {
|
|
@@ -25920,18 +25929,18 @@ class MarketWebContextService {
|
|
|
25920
25929
|
if (environmentName === this.environments.production.name) {
|
|
25921
25930
|
if (this.wwwMarkets.indexOf(marketName) !== -1) {
|
|
25922
25931
|
// Handles www.postnord.xx domains
|
|
25923
|
-
url = url.replace(
|
|
25932
|
+
url = url.replace('.xx', '.' + marketName);
|
|
25924
25933
|
}
|
|
25925
25934
|
else {
|
|
25926
|
-
url = url.replace(
|
|
25927
|
-
url = url.replace(
|
|
25935
|
+
url = url.replace('.xx', '.com'); // Expect URL to end in postnord.com
|
|
25936
|
+
url = url.replace('www.', marketName + '.');
|
|
25928
25937
|
}
|
|
25929
25938
|
}
|
|
25930
25939
|
}
|
|
25931
25940
|
return url;
|
|
25932
25941
|
}
|
|
25933
25942
|
async getEnvironmentName() {
|
|
25934
|
-
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf(
|
|
25943
|
+
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf('-' + x) !== -1)[0];
|
|
25935
25944
|
if (likelyEnvironment) {
|
|
25936
25945
|
this.environment = likelyEnvironment;
|
|
25937
25946
|
return this.environment;
|
|
@@ -25949,17 +25958,17 @@ class MarketWebContextService {
|
|
|
25949
25958
|
}
|
|
25950
25959
|
async resolveMarket() {
|
|
25951
25960
|
// Resolve market from www domains
|
|
25952
|
-
if (this.href.indexOf(
|
|
25961
|
+
if (this.href.indexOf('//www.') !== -1) {
|
|
25953
25962
|
const domainRoot = this.url.hostname.substring(this.url.hostname.lastIndexOf('.') + 1, this.url.hostname.length);
|
|
25954
25963
|
if (domainRoot && this.markets[domainRoot]) {
|
|
25955
25964
|
this.market = domainRoot;
|
|
25956
25965
|
}
|
|
25957
25966
|
else {
|
|
25958
|
-
console.warn(
|
|
25967
|
+
console.warn('Unable to define market from www. domain', this.href);
|
|
25959
25968
|
}
|
|
25960
25969
|
}
|
|
25961
25970
|
// Check if domains are on one of the integration/preproduction/production environments urls
|
|
25962
|
-
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf(
|
|
25971
|
+
const likelyEnvironment = this.environmentTypes.filter(x => this.url.hostname.indexOf('-' + x) !== -1);
|
|
25963
25972
|
if (!this.market && likelyEnvironment && likelyEnvironment.length > 0) {
|
|
25964
25973
|
const matchedEnvironment = likelyEnvironment[0];
|
|
25965
25974
|
const marketPrefix = this.url.hostname.substring(0, this.url.hostname.indexOf('-' + matchedEnvironment));
|
|
@@ -25967,14 +25976,14 @@ class MarketWebContextService {
|
|
|
25967
25976
|
this.market = marketPrefix;
|
|
25968
25977
|
}
|
|
25969
25978
|
else {
|
|
25970
|
-
console.warn(
|
|
25979
|
+
console.warn('Unable to define market from preset environment names', this.href);
|
|
25971
25980
|
}
|
|
25972
25981
|
}
|
|
25973
25982
|
if (!this.market) {
|
|
25974
25983
|
if (this.url.hostname.indexOf('www') === -1 && this.url.hostname.indexOf('.postnord.') > 0) {
|
|
25975
25984
|
const start = this.url.hostname.indexOf('.') !== this.url.hostname.indexOf('.postnord') ? this.url.hostname.indexOf('.') : 0;
|
|
25976
25985
|
const potentialMarket = this.url.hostname.substring(start, this.url.hostname.indexOf('.postnord.'));
|
|
25977
|
-
// Break down the subdomain to the word closest to .postnord. and take that word.
|
|
25986
|
+
// Break down the subdomain to the word closest to .postnord. and take that word.
|
|
25978
25987
|
// Supports sub-sub domain down to 1 level.
|
|
25979
25988
|
if (this.allowedMarkets.indexOf(potentialMarket) !== -1) {
|
|
25980
25989
|
this.market = potentialMarket;
|
|
@@ -25982,7 +25991,7 @@ class MarketWebContextService {
|
|
|
25982
25991
|
}
|
|
25983
25992
|
}
|
|
25984
25993
|
}
|
|
25985
|
-
// Check if we're on a development environment
|
|
25994
|
+
// Check if we're on a development environment
|
|
25986
25995
|
if (!this.market) {
|
|
25987
25996
|
const matchedDevEnvironment = this.developmentDomains.filter(x => this.url.hostname.indexOf(x) !== -1)[0];
|
|
25988
25997
|
if (!matchedDevEnvironment) {
|
|
@@ -25990,7 +25999,7 @@ class MarketWebContextService {
|
|
|
25990
25999
|
this.market = this.allowedMarkets[0];
|
|
25991
26000
|
return;
|
|
25992
26001
|
}
|
|
25993
|
-
const urlWithoutDomain = this.href.replace(matchedDevEnvironment,
|
|
26002
|
+
const urlWithoutDomain = this.href.replace(matchedDevEnvironment, '');
|
|
25994
26003
|
// We see if the dev environment contains something like /dk
|
|
25995
26004
|
let matchedMarket = this.allowedMarkets.filter(x => {
|
|
25996
26005
|
const typesOfFallback = ['.' + x, x + '.', '/' + x + '/']; // Ex /dk, dk.html, /dk/
|
|
@@ -26002,7 +26011,7 @@ class MarketWebContextService {
|
|
|
26002
26011
|
}
|
|
26003
26012
|
else {
|
|
26004
26013
|
// We do a similar filter for subpaths but for language this time
|
|
26005
|
-
let filteredMarket = Object.entries(this.markets).filter(
|
|
26014
|
+
let filteredMarket = Object.entries(this.markets).filter(item => {
|
|
26006
26015
|
const typesOfFallback = ['.' + item[1].fallbackLanguage, item[1].fallbackLanguage + '.', '/' + item[1].fallbackLanguage + '/']; // Ex /dk, dk.html, /dk/
|
|
26007
26016
|
const matchedTypeOfFallback = typesOfFallback.filter(y => urlWithoutDomain.indexOf(y) !== -1);
|
|
26008
26017
|
return matchedTypeOfFallback.length > 0;
|
|
@@ -26013,7 +26022,7 @@ class MarketWebContextService {
|
|
|
26013
26022
|
}
|
|
26014
26023
|
}
|
|
26015
26024
|
if (!this.market) {
|
|
26016
|
-
console.info(
|
|
26025
|
+
console.info('Was unable to detect market, used fallback');
|
|
26017
26026
|
this.market = this.allowedMarkets[0];
|
|
26018
26027
|
}
|
|
26019
26028
|
}
|
|
@@ -26023,12 +26032,14 @@ class MarketWebContextService {
|
|
|
26023
26032
|
return;
|
|
26024
26033
|
}
|
|
26025
26034
|
const potentialLanguages = [
|
|
26026
|
-
(_a = document.querySelector(
|
|
26027
|
-
(_b = document.querySelector('[http-equiv="content-language"][content]')) === null || _b === void 0 ? void 0 : _b.getAttribute(
|
|
26028
|
-
(_c = document.querySelector('[property="og:locale"][content]')) === null || _c === void 0 ? void 0 : _c.getAttribute(
|
|
26029
|
-
(_d = document.querySelector(
|
|
26035
|
+
(_a = document.querySelector('html[lang]')) === null || _a === void 0 ? void 0 : _a.getAttribute('lang'),
|
|
26036
|
+
(_b = document.querySelector('[http-equiv="content-language"][content]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content'),
|
|
26037
|
+
(_c = document.querySelector('[property="og:locale"][content]')) === null || _c === void 0 ? void 0 : _c.getAttribute('content'),
|
|
26038
|
+
(_d = document.querySelector('[lang]')) === null || _d === void 0 ? void 0 : _d.getAttribute('lang'),
|
|
26030
26039
|
];
|
|
26031
|
-
potentialLanguages
|
|
26040
|
+
potentialLanguages
|
|
26041
|
+
.filter(x => x)
|
|
26042
|
+
.forEach(language => {
|
|
26032
26043
|
if (this.allowedLanguages.indexOf(language)) {
|
|
26033
26044
|
this.language = language;
|
|
26034
26045
|
return;
|