@sitecore-jss/sitecore-jss-nextjs 22.2.0-canary.75 → 22.2.0-canary.77
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.
|
@@ -42,6 +42,10 @@ const react_1 = __importStar(require("react"));
|
|
|
42
42
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
43
43
|
const link_1 = __importDefault(require("next/link"));
|
|
44
44
|
const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
45
|
+
/**
|
|
46
|
+
* Matches relative URLs that end with a file extension.
|
|
47
|
+
*/
|
|
48
|
+
const FILE_EXTENSION_MATCHER = /^\/.*\.\w+$/;
|
|
45
49
|
exports.Link = (0, react_1.forwardRef)((props, ref) => {
|
|
46
50
|
const { field, editable = true, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, htmlLinkProps = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
|
|
47
51
|
if (!field ||
|
|
@@ -59,8 +63,10 @@ exports.Link = (0, react_1.forwardRef)((props, ref) => {
|
|
|
59
63
|
const isEditing = editable && (field.editable || field.metadata);
|
|
60
64
|
if (href && !isEditing) {
|
|
61
65
|
const text = showLinkTextWithChildrenPresent || !children ? value.text || value.href : null;
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
const isMatching = internalLinkMatcher.test(href);
|
|
67
|
+
const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
|
|
68
|
+
// determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
|
|
69
|
+
if (isMatching && !isFileUrl) {
|
|
64
70
|
return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", locale: false, title: value.title, target: value.target, className: value.class }, htmlLinkProps, { ref: ref }),
|
|
65
71
|
text,
|
|
66
72
|
children));
|
|
@@ -13,6 +13,10 @@ import React, { forwardRef } from 'react';
|
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import NextLink from 'next/link';
|
|
15
15
|
import { Link as ReactLink, LinkPropTypes, } from '@sitecore-jss/sitecore-jss-react';
|
|
16
|
+
/**
|
|
17
|
+
* Matches relative URLs that end with a file extension.
|
|
18
|
+
*/
|
|
19
|
+
const FILE_EXTENSION_MATCHER = /^\/.*\.\w+$/;
|
|
16
20
|
export const Link = forwardRef((props, ref) => {
|
|
17
21
|
const { field, editable = true, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, htmlLinkProps = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
|
|
18
22
|
if (!field ||
|
|
@@ -30,8 +34,10 @@ export const Link = forwardRef((props, ref) => {
|
|
|
30
34
|
const isEditing = editable && (field.editable || field.metadata);
|
|
31
35
|
if (href && !isEditing) {
|
|
32
36
|
const text = showLinkTextWithChildrenPresent || !children ? value.text || value.href : null;
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
const isMatching = internalLinkMatcher.test(href);
|
|
38
|
+
const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
|
|
39
|
+
// determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
|
|
40
|
+
if (isMatching && !isFileUrl) {
|
|
35
41
|
return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", locale: false, title: value.title, target: value.target, className: value.class }, htmlLinkProps, { ref: ref }),
|
|
36
42
|
text,
|
|
37
43
|
children));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "22.2.0-canary.
|
|
3
|
+
"version": "22.2.0-canary.77",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"react-dom": "^18.2.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sitecore-jss/sitecore-jss": "^22.2.0-canary.
|
|
76
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^22.2.0-canary.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-react": "^22.2.0-canary.
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "^22.2.0-canary.77",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^22.2.0-canary.77",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "^22.2.0-canary.77",
|
|
78
78
|
"@vercel/kv": "^0.2.1",
|
|
79
79
|
"prop-types": "^15.8.1",
|
|
80
80
|
"regex-parser": "^2.2.11",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"description": "",
|
|
84
84
|
"types": "types/index.d.ts",
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "13a3f0405c59d639a4279dd375b1b9a1e4c40a4b",
|
|
86
86
|
"files": [
|
|
87
87
|
"dist",
|
|
88
88
|
"types",
|