@jetshop/core 5.14.0-alpha.49df897e → 5.14.0-alpha.abd04298

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ export const getGroupedChannels = (availableChannels, { groupName }) => {
7
7
  return undefined;
8
8
  }
9
9
  const selectedChannelGroup = availableChannels.filter((channel) => channel.groupName === currentChannel.groupName);
10
- if (selectedChannelGroup) {
10
+ if (selectedChannelGroup.length > 0) {
11
11
  return selectedChannelGroup;
12
12
  }
13
13
  else {
@@ -191,68 +191,8 @@ function setGeoIpAndAcceptLanguageCookies({ cookies, geoipCountry, acceptLanguag
191
191
  path: '/'
192
192
  });
193
193
  }
194
- function getGroupedChannelsByUrl({ url, channels, singleDomainMode, cookies, geoipCountry }) {
195
- const hasGroupedChannels = allChannelsGrouped(channels);
196
- if (!hasGroupedChannels) {
197
- return {
198
- hasGroupedChannels,
199
- groupByChannel: undefined
200
- };
201
- }
202
- switch (true) {
203
- case isInDev(url): {
204
- if (singleDomainMode) {
205
- const currentBaseUrl = getURLBasename(new URL(url));
206
- // -> se, de, dk, es etcetc
207
- return {
208
- hasGroupedChannels,
209
- groupByChannel: channels.find((channel) =>
210
- // We always split channel.url to consider if trailing slashes are added in as BaseUrl
211
- sanitizeURL(channel.url).split('/')[1] === currentBaseUrl)
212
- };
213
- }
214
- else {
215
- // Try to match with anything during development + non-singledomain,
216
- // this is b/c we can't match dev urls with any baseurl.
217
- // If one wan't to test it in dev one can use the ?channel=XX param.
218
- const { activeChannel, chosenChannel } = getCurrentChannel({
219
- url,
220
- singleDomainMode,
221
- channels,
222
- cookies,
223
- geoipCountry
224
- });
225
- return {
226
- hasGroupedChannels,
227
- // Active channel is given first priority. If it is null we are most likely in staging or development so chosenChannel or defaultChannel is used
228
- groupByChannel: activeChannel || chosenChannel || getDefaultChannel(channels)
229
- };
230
- }
231
- }
232
- case singleDomainMode: {
233
- const currentBaseUrl = sanitizeURL(url).split('/', 2);
234
- // -> se, de, dk, es etcetc
235
- return {
236
- hasGroupedChannels,
237
- groupByChannel: channels.find((channel) =>
238
- // We always split channel.url to consider if trailing slashes are added in as BaseUrl
239
- sanitizeURL(channel.url).split('/')[1] === currentBaseUrl[1]) || getDefaultChannel(channels)
240
- };
241
- }
242
- default: {
243
- const currentBaseUrl = sanitizeURL(url).split('/')[0];
244
- // -> domain.com
245
- return {
246
- hasGroupedChannels,
247
- groupByChannel: channels.find((channel) =>
248
- // We always split channel.url to consider if trailing slashes are added in as BaseUrl
249
- sanitizeURL(channel.url).split('/')[0] === currentBaseUrl)
250
- };
251
- }
252
- }
253
- }
254
194
  // Is where we determine current channel to get return values in getSelectedAndRecommendedChannel
255
- function getCurrentChannel({ url, singleDomainMode, channels, cookies, geoipCountry }) {
195
+ function getCurrentChannel({ url, singleDomainMode, channels, cookies }) {
256
196
  const { activeChannel, activeChannels } = getChannelFromPathOrUrl({
257
197
  url,
258
198
  singleDomainMode,
@@ -262,42 +202,34 @@ function getCurrentChannel({ url, singleDomainMode, channels, cookies, geoipCoun
262
202
  cookies,
263
203
  channels
264
204
  });
265
- const channelFromGeoIp = findChannelByCountry(geoipCountry || cookies.get('geoipCountry'), channels);
266
205
  // But have default channel as fallback,
267
206
  const defaultChannel = getDefaultChannel(channels);
268
207
  return {
269
208
  activeChannel,
270
209
  activeChannels,
271
210
  chosenChannel,
272
- channelFromGeoIp,
273
211
  defaultChannel
274
212
  };
275
213
  }
276
214
  export function getSelectedAndRecommendedChannel({ url, singleDomainMode, channels, cookies, geoipCountry, acceptedLanguages, disableGeoRedirect }) {
277
215
  setCookiesFromQueryString({ cookies, url });
278
- const { hasGroupedChannels, groupByChannel } = getGroupedChannelsByUrl({
216
+ const { defaultChannel, chosenChannel, activeChannel, activeChannels } = getCurrentChannel({
279
217
  url,
280
- channels,
281
218
  singleDomainMode,
219
+ channels,
282
220
  cookies,
283
221
  geoipCountry
284
222
  });
285
- // If available, use channel group from here on
223
+ // Active channel is given first priority. If it is null we are most likely in staging or development so chosenChannel or defaultChannel is used
224
+ // Definitions: Requested channel by url || Channel stored in cookies || Default channel
225
+ const pureChannel = activeChannel || chosenChannel || defaultChannel;
286
226
  // NB: All channels must be grouped and groupName is nullable.
287
- const availableChannels = hasGroupedChannels && (groupByChannel === null || groupByChannel === void 0 ? void 0 : groupByChannel.groupName)
227
+ const availableChannels = allChannelsGrouped(channels)
288
228
  ? getGroupedChannels(channels, {
289
- groupName: groupByChannel.groupName
229
+ groupName: pureChannel.groupName
290
230
  })
291
231
  : channels;
292
- const { defaultChannel, chosenChannel, activeChannel, activeChannels, channelFromGeoIp } = getCurrentChannel({
293
- url,
294
- singleDomainMode,
295
- channels: availableChannels,
296
- cookies,
297
- geoipCountry
298
- });
299
- // Active channel is given first priority. If it is null we are most likely in staging or development so chosenChannel or defaultChannel is used
300
- const pureChannel = activeChannel || chosenChannel || defaultChannel;
232
+ const channelFromGeoIp = findChannelByCountry(geoipCountry || cookies.get('geoipCountry'), availableChannels);
301
233
  let redirect = false;
302
234
  let pureRecommendedChannel;
303
235
  // If a channel has been chosen we want to redirect to it
@@ -305,14 +237,21 @@ export function getSelectedAndRecommendedChannel({ url, singleDomainMode, channe
305
237
  activeChannel &&
306
238
  activeChannel.id !== chosenChannel.id &&
307
239
  // We don't want to redirect if the URLs of the channels are the same (i.e. demostore)
308
- chosenChannel.url !== activeChannel.url) {
240
+ chosenChannel.url !== activeChannel.url &&
241
+ // It is safe to redirect if the channel is part of the same group
242
+ (chosenChannel === null || chosenChannel === void 0 ? void 0 : chosenChannel.groupName) === (activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.groupName)) {
309
243
  redirect = true;
310
244
  pureRecommendedChannel = chosenChannel;
311
245
  }
312
- else if (channelFromGeoIp && pureChannel.id !== channelFromGeoIp.id) {
246
+ else if (channelFromGeoIp &&
247
+ // Recommend channel if it not the same as the current channel
248
+ pureChannel.id !== channelFromGeoIp.id &&
249
+ // Or is available in channel group
250
+ (pureChannel === null || pureChannel === void 0 ? void 0 : pureChannel.groupName) === (channelFromGeoIp === null || channelFromGeoIp === void 0 ? void 0 : channelFromGeoIp.groupName)) {
313
251
  pureRecommendedChannel = channelFromGeoIp;
252
+ // Allow redirect if there's no channel in cookies (chosenChannel)
314
253
  redirect = !disableGeoRedirect && !chosenChannel;
315
- // this should happen when we can't find a matching channel from the url so we want to redirect such that the basename is included
254
+ // the following should happen when we can't find a matching channel from the url so we want to redirect such that the basename is included
316
255
  }
317
256
  else if (!activeChannel &&
318
257
  singleDomainMode &&
@@ -1 +1 @@
1
- {"version":3,"file":"channelUtils.js","sourceRoot":"","sources":["channelUtils.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,MAAM,IAAI,CAAC;AAapB,MAAM,kBAAkB,GAAG,CAAC,iBAA4B,EAAE,EAAE,CAC1D,iBAAiB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,WAAC,OAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,CAAA,EAAA,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,iBAA4B,EAC5B,EAAE,SAAS,EAAyB,EACtB,EAAE;IAChB,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAC3C,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAC7C,CAAC;IAEF,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,MAAM,CACnD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,KAAK,cAAc,CAAC,SAAS,CAC5D,CAAC;IAEF,IAAI,oBAAoB,EAAE;QACxB,OAAO,oBAAoB,CAAC;KAC7B;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAQ,EAAE,EA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QAAQ,GAAG,IAAI,CAAC;QAChB,sBAAsB,GAAG,WAAW,CAAC;KACtC;IAED,MAAM,kBAAkB,GACtB,sBAAsB;QACtB,qBAAqB,CACnB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,CACpB,CAAC;IAEJ,OAAO;QACL,QAAQ;QACR,eAAe;QACf,kBAAkB;QAClB,8BAA8B;QAC9B,QAAQ,EAAE,iBAAiB;KAC5B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAyB;IACzD,OAAO,OAAO;QACZ,CAAC,CAAC;YACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC7B,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO;YACjC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;YAC7B,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB;QACH,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
@@ -176,15 +176,6 @@ const selectedChannelSingleDomain = createSelectedChannel(
176
176
  singleDomainChannels[0]
177
177
  );
178
178
 
179
- describe('Channel grouping', () => {
180
- beforeEach(() => {
181
- // Workaround changes in universal-cookie
182
- Object.defineProperty(document, 'cookie', {
183
- value: null
184
- });
185
- });
186
- });
187
-
188
179
  describe('Grouped channels', () => {
189
180
  beforeEach(() => {
190
181
  // Workaround changes in universal-cookie
@@ -319,46 +310,107 @@ describe('Grouped channels', () => {
319
310
  });
320
311
  });
321
312
  describe('Redirects', () => {
322
- it('Does not redirect to channel outside of current group', () => {
323
- const cookies = new Cookies();
324
- const selectedChannel = createSelectedChannel(channels[2]);
325
- cookies.set('channel', selectedChannel.name);
313
+ beforeEach(() => {
314
+ // Workaround changes in universal-cookie
315
+ Object.defineProperty(document, 'cookie', {
316
+ value: null
317
+ });
318
+ });
319
+ describe('Single domain', () => {
320
+ it('Will not georedirect to channel outside of current group', () => {
321
+ const cookies = new Cookies();
322
+ const requestedChannel = createSelectedChannel(singleDomainChannels[0]);
323
+
324
+ const {
325
+ redirect,
326
+ channels: availableChannel,
327
+ selectedChannel
328
+ } = getSelectedAndRecommendedChannel({
329
+ url: requestedChannel.url,
330
+ singleDomainMode: true,
331
+ disableGeoRedirect: false,
332
+ channels: singleDomainChannels,
333
+ cookies,
334
+ geoipCountry: 'UK'
335
+ });
326
336
 
327
- const recommendedChannel = createSelectedChannel(channels[0]);
337
+ expect(selectedChannel.name === requestedChannel.name).toBe(true);
338
+ expect(redirect).toBe(false);
328
339
 
329
- const { redirect, channels: availableChannel } =
330
- getSelectedAndRecommendedChannel({
331
- url: recommendedChannel.url,
332
- singleDomainMode: false,
333
- channels,
334
- cookies
340
+ availableChannel.forEach((channel) =>
341
+ expect(channel.groupName).toBe('Brand-1')
342
+ );
343
+ });
344
+ it('Will georedirect to channel within of current group', () => {
345
+ const cookies = new Cookies();
346
+ const requestedChannel = createSelectedChannel(singleDomainChannels[0]);
347
+
348
+ const {
349
+ redirect,
350
+ channels: availableChannel,
351
+ selectedChannel,
352
+ recommendedChannel
353
+ } = getSelectedAndRecommendedChannel({
354
+ url: requestedChannel.url,
355
+ singleDomainMode: true,
356
+ disableGeoRedirect: false,
357
+ channels: singleDomainChannels,
358
+ cookies,
359
+ geoipCountry: 'SE'
335
360
  });
336
361
 
337
- availableChannel.forEach((channel) =>
338
- expect(channel.groupName).toBe('Brand-1')
339
- );
340
- expect(redirect).toBe(false);
362
+ expect(selectedChannel.name).toBe('INT');
363
+ expect(redirect).toBe(true);
364
+ expect(recommendedChannel.name).toBe('SE');
365
+
366
+ availableChannel.forEach((channel) =>
367
+ expect(channel.groupName).toBe('Brand-1')
368
+ );
369
+ });
341
370
  });
342
371
 
343
- it('Can redirect to channel within group', () => {
344
- const cookies = new Cookies();
345
- const selectedChannel = createSelectedChannel(channels[1]);
346
- cookies.set('channel', selectedChannel.name);
372
+ describe('Non-single domain', () => {
373
+ it('Wil not redirect to channel within group', () => {
374
+ const cookies = new Cookies();
375
+ const selectedChannel = createSelectedChannel(channels[2]);
376
+ cookies.set('channel', selectedChannel.name);
347
377
 
348
- const recommendedChannel = createSelectedChannel(channels[0]);
378
+ const requestedChannel = createSelectedChannel(channels[0]);
349
379
 
350
- const { redirect, channels: availableChannel } =
351
- getSelectedAndRecommendedChannel({
352
- url: recommendedChannel.url,
353
- singleDomainMode: false,
354
- channels,
355
- cookies
356
- });
380
+ const { redirect, channels: availableChannel } =
381
+ getSelectedAndRecommendedChannel({
382
+ url: requestedChannel.url,
383
+ singleDomainMode: false,
384
+ channels,
385
+ cookies
386
+ });
357
387
 
358
- availableChannel.forEach((channel) =>
359
- expect(channel.groupName).toBe('Brand-1')
360
- );
361
- expect(redirect).toBe(true);
388
+ availableChannel.forEach((channel) =>
389
+ expect(channel.groupName).toBe('Brand-1')
390
+ );
391
+ expect(redirect).toBe(false);
392
+ });
393
+
394
+ it('Can redirect to channel within group', () => {
395
+ const cookies = new Cookies();
396
+ const selectedChannel = createSelectedChannel(channels[1]);
397
+ cookies.set('channel', selectedChannel.name);
398
+
399
+ const requestedChannel = createSelectedChannel(channels[0]);
400
+
401
+ const { redirect, channels: availableChannel } =
402
+ getSelectedAndRecommendedChannel({
403
+ url: requestedChannel.url,
404
+ singleDomainMode: false,
405
+ channels,
406
+ cookies
407
+ });
408
+
409
+ availableChannel.forEach((channel) =>
410
+ expect(channel.groupName).toBe('Brand-1')
411
+ );
412
+ expect(redirect).toBe(true);
413
+ });
362
414
  });
363
415
  });
364
416
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetshop/core",
3
- "version": "5.14.0-alpha.49df897e",
3
+ "version": "5.14.0-alpha.abd04298",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -6,6 +6,7 @@ export const channels = [
6
6
  name: 'INT',
7
7
  isDefault: true,
8
8
  displayName: 'International',
9
+ groupName: null,
9
10
  url: 'https://flight.jetshop.se',
10
11
  countries: [
11
12
  {
@@ -486,6 +487,7 @@ export const channels = [
486
487
  name: 'SE',
487
488
  isDefault: false,
488
489
  displayName: null,
490
+ groupName: null,
489
491
  url: 'https://flight-m2.jetshop.se',
490
492
  countries: [
491
493
  {
@@ -554,6 +556,7 @@ export const channels = [
554
556
  name: 'UK',
555
557
  isDefault: false,
556
558
  displayName: null,
559
+ groupName: null,
557
560
  url: 'https://flight-m2.jetshop.uk',
558
561
  countries: [
559
562
  {
@@ -620,6 +623,7 @@ export const singleDomainChannels = [
620
623
  name: 'INT',
621
624
  isDefault: true,
622
625
  displayName: 'International',
626
+ groupName: null,
623
627
  url: 'https://flight.jetshop.se/int',
624
628
  countries: [
625
629
  {
@@ -1100,6 +1104,7 @@ export const singleDomainChannels = [
1100
1104
  name: 'SE',
1101
1105
  isDefault: false,
1102
1106
  displayName: null,
1107
+ groupName: null,
1103
1108
  url: 'https://flight-m2.jetshop.se/se',
1104
1109
  countries: [
1105
1110
  {
@@ -1168,6 +1173,7 @@ export const singleDomainChannels = [
1168
1173
  name: 'UK',
1169
1174
  isDefault: false,
1170
1175
  displayName: null,
1176
+ groupName: null,
1171
1177
  url: 'https://flight-m2.jetshop.se/uk',
1172
1178
  countries: [
1173
1179
  {
@@ -2408,6 +2414,11 @@ export const groupedSingleDomainChannels = [
2408
2414
  name: 'United Kingdom',
2409
2415
  code: 'UK',
2410
2416
  isDefault: true
2417
+ },
2418
+ {
2419
+ name: 'Sweden',
2420
+ code: 'SE',
2421
+ isDefault: false
2411
2422
  }
2412
2423
  ],
2413
2424
  languages: [