@financial-times/dotcom-ui-shell 5.0.0 → 6.0.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.
@@ -13,8 +13,11 @@ const ResourceHints = (props) => {
13
13
  react_1.default.createElement("link", { rel: "preconnect", href: "https://ads-api.ft.com" }),
14
14
  react_1.default.createElement("link", { rel: "preconnect", href: "https://securepubads.g.doubleclick.net" }),
15
15
  props.resourceHints.map((resource, i) => {
16
+ var _a;
16
17
  const contentType = getResourceType_1.default(resource);
17
- const mimeType = mime_types_1.default.lookup(resource) || null;
18
+ const mimeType = mime_types_1.default.lookup(resource) ||
19
+ mime_types_1.default.lookup((_a = resource.match(/(?<=font_format=)([a-z0-9]+)/)) === null || _a === void 0 ? void 0 : _a[0]) ||
20
+ null;
18
21
  const attributes = {
19
22
  as: contentType,
20
23
  href: resource,
@@ -8,7 +8,6 @@ const url_1 = __importDefault(require("url"));
8
8
  const StyleFiles = new Set(['.css']);
9
9
  const ScriptFiles = new Set(['.js', '.mjs']);
10
10
  const ImageFiles = new Set(['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp']);
11
- const FontFiles = new Set(['.woff', '.woff2', '.otf', '.ttf', '.eot']);
12
11
  exports.default = (file) => {
13
12
  // Always parse the file so that we can ignore any domain names, query strings etc.
14
13
  // Node's old URL API is able to parse anything inc. filenames, paths, and URLs.
@@ -23,7 +22,7 @@ exports.default = (file) => {
23
22
  if (ImageFiles.has(extension)) {
24
23
  return 'image';
25
24
  }
26
- if (FontFiles.has(extension)) {
25
+ if (file.includes('font_format=woff')) {
27
26
  return 'font';
28
27
  }
29
28
  throw Error(`Unknown filename extension "${extension}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-ui-shell",
3
- "version": "5.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "",
5
5
  "main": "component.js",
6
6
  "browser": "browser.js",
@@ -21,11 +21,11 @@
21
21
  "author": "",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@financial-times/dotcom-ui-app-context": "^5.0.0",
25
- "@financial-times/dotcom-ui-base-styles": "^5.0.0",
26
- "@financial-times/dotcom-ui-bootstrap": "^5.0.0",
27
- "@financial-times/dotcom-ui-flags": "^5.0.0",
28
- "@financial-times/dotcom-ui-polyfill-service": "^5.0.0",
24
+ "@financial-times/dotcom-ui-app-context": "^6.0.1",
25
+ "@financial-times/dotcom-ui-base-styles": "^6.0.1",
26
+ "@financial-times/dotcom-ui-bootstrap": "^6.0.1",
27
+ "@financial-times/dotcom-ui-flags": "^6.0.1",
28
+ "@financial-times/dotcom-ui-polyfill-service": "^6.0.1",
29
29
  "mime-types": "^2.1.26"
30
30
  },
31
31
  "peerDependencies": {
@@ -32,7 +32,10 @@ const ResourceHints = (props: TResourceHintsProps) => {
32
32
 
33
33
  {props.resourceHints.map((resource, i) => {
34
34
  const contentType = getResourceType(resource)
35
- const mimeType = mimeTypes.lookup(resource) || null
35
+ const mimeType =
36
+ mimeTypes.lookup(resource) ||
37
+ mimeTypes.lookup(resource.match(/(?<=font_format=)([a-z0-9]+)/)?.[0]) ||
38
+ null
36
39
 
37
40
  const attributes: React.LinkHTMLAttributes<HTMLLinkElement> = {
38
41
  as: contentType,
@@ -51,7 +51,8 @@ function Shell(props: TShellProps) {
51
51
  lang="en-GB"
52
52
  className={`no-js core ${loadCustomFontsClassNames}`}
53
53
  data-o-component="o-typography"
54
- style={documentStyles}>
54
+ style={documentStyles}
55
+ >
55
56
  <head>
56
57
  <DocumentHead {...props} />
57
58
  <ResourceHints resourceHints={resourceHints} />
@@ -7,8 +7,6 @@ const ScriptFiles = new Set(['.js', '.mjs'])
7
7
 
8
8
  const ImageFiles = new Set(['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp'])
9
9
 
10
- const FontFiles = new Set(['.woff', '.woff2', '.otf', '.ttf', '.eot'])
11
-
12
10
  export default (file: string): string => {
13
11
  // Always parse the file so that we can ignore any domain names, query strings etc.
14
12
  // Node's old URL API is able to parse anything inc. filenames, paths, and URLs.
@@ -28,7 +26,7 @@ export default (file: string): string => {
28
26
  return 'image'
29
27
  }
30
28
 
31
- if (FontFiles.has(extension)) {
29
+ if (file.includes('font_format=woff')) {
32
30
  return 'font'
33
31
  }
34
32