@financial-times/dotcom-middleware-navigation 11.3.0 → 12.0.0

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.
@@ -9,7 +9,7 @@ exports.default = (request, response) => {
9
9
  // <https://github.com/Financial-Times/ft.com-cdn/blob/HEAD/src/vcl/next-editions.vcl>
10
10
  // <https://github.com/Financial-Times/next-router/blob/HEAD/server/middleware/editions.js>
11
11
  let currentEdition = request.get('FT-Edition') || defaultEdition;
12
- if (typeof request.query.edition === 'string' && dotcom_server_navigation_1.isEdition(request.query.edition)) {
12
+ if (typeof request.query.edition === 'string' && (0, dotcom_server_navigation_1.isEdition)(request.query.edition)) {
13
13
  currentEdition = request.query.edition;
14
14
  response.cookie('next-edition', currentEdition, {
15
15
  domain: 'ft.com',
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,6 +1,6 @@
1
1
  import { Request, Response, NextFunction } from 'express';
2
2
  import { TNavOptions } from '@financial-times/dotcom-server-navigation';
3
- declare type MiddlewareOptions = TNavOptions & {
3
+ type MiddlewareOptions = TNavOptions & {
4
4
  enableSubNavigation?: boolean;
5
5
  getCurrentPath?: Function;
6
6
  };
@@ -9,7 +9,7 @@ const handleEdition_1 = __importDefault(require("./handleEdition"));
9
9
  const normalizePath_1 = __importDefault(require("./normalizePath"));
10
10
  const defaultOptions = {
11
11
  enableSubNavigation: false,
12
- getCurrentPath: (request) => normalizePath_1.default(request.get('ft-vanity-url') || request.path)
12
+ getCurrentPath: (request) => (0, normalizePath_1.default)(request.get('ft-vanity-url') || request.path)
13
13
  };
14
14
  const init = (userOptions = {}) => {
15
15
  const options = { ...defaultOptions, ...userOptions };
@@ -24,7 +24,7 @@ const init = (userOptions = {}) => {
24
24
  // <https://github.com/Financial-Times/ft.com-cdn/blob/4841fbf100e1c561a2f6729b9921ec12bb6b837c/src/vcl/next-preflight.vcl#L213-L219>
25
25
  // NOTE: Next router sets the vanity header inc. any query string so it must be normalized.
26
26
  const currentPath = options.getCurrentPath(request);
27
- const currentEdition = handleEdition_1.default(request, response);
27
+ const currentEdition = (0, handleEdition_1.default)(request, response);
28
28
  const [menusData, subNavigationData] = await Promise.all([
29
29
  navigation.getMenusFor(currentPath, currentEdition),
30
30
  options.enableSubNavigation ? getSubNavigationFor(currentPath) : null
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = normalizePath;
6
7
  const url_1 = __importDefault(require("url"));
7
8
  function normalizePath(currentPath) {
8
9
  // NOTE: We're using Node's old URL API because it can handle partial URLs
9
10
  return url_1.default.parse(currentPath).pathname || '';
10
11
  }
11
- exports.default = normalizePath;