gatsby-link 4.7.0-next.0 → 4.7.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/CHANGELOG.md +6 -0
- package/index.js +11 -37
- package/is-local-link.js +2 -1
- package/package.json +5 -4
- package/rewrite-link-path.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.6.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-link@4.6.0/packages/gatsby-link) (2022-01-25)
|
|
7
|
+
|
|
8
|
+
[🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.6)
|
|
9
|
+
|
|
10
|
+
**Note:** Version bump only for package gatsby-link
|
|
11
|
+
|
|
6
12
|
## [4.5.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-link@4.5.0/packages/gatsby-link) (2022-01-11)
|
|
7
13
|
|
|
8
14
|
[🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.5)
|
package/index.js
CHANGED
|
@@ -21,16 +21,15 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
21
21
|
|
|
22
22
|
var _reachRouter = require("@gatsbyjs/reach-router");
|
|
23
23
|
|
|
24
|
-
var _utils = require("@gatsbyjs/reach-router/lib/utils");
|
|
25
|
-
|
|
26
24
|
var _parsePath = require("./parse-path");
|
|
27
25
|
|
|
28
26
|
exports.parsePath = _parsePath.parsePath;
|
|
29
|
-
var _excluded = ["to", "getProps", "onClick", "onMouseEnter", "activeClassName", "activeStyle", "innerRef", "partiallyActive", "state", "replace", "_location"];
|
|
30
27
|
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
var _isLocalLink = require("./is-local-link");
|
|
29
|
+
|
|
30
|
+
var _rewriteLinkPath = require("./rewrite-link-path");
|
|
31
|
+
|
|
32
|
+
var _excluded = ["to", "getProps", "onClick", "onMouseEnter", "activeClassName", "activeStyle", "innerRef", "partiallyActive", "state", "replace", "_location"];
|
|
34
33
|
|
|
35
34
|
function withPrefix(path, prefix) {
|
|
36
35
|
var _ref, _prefix;
|
|
@@ -39,7 +38,7 @@ function withPrefix(path, prefix) {
|
|
|
39
38
|
prefix = getGlobalBasePrefix();
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
if (!isLocalLink(path)) {
|
|
41
|
+
if (!(0, _isLocalLink.isLocalLink)(path)) {
|
|
43
42
|
return path;
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -61,35 +60,10 @@ var getGlobalBasePrefix = function getGlobalBasePrefix() {
|
|
|
61
60
|
return process.env.NODE_ENV !== "production" ? typeof __BASE_PATH__ !== "undefined" ? __BASE_PATH__ : undefined : __BASE_PATH__;
|
|
62
61
|
};
|
|
63
62
|
|
|
64
|
-
var isLocalLink = function isLocalLink(path) {
|
|
65
|
-
return path && !path.startsWith("http://") && !path.startsWith("https://") && !path.startsWith("//");
|
|
66
|
-
};
|
|
67
|
-
|
|
68
63
|
function withAssetPrefix(path) {
|
|
69
64
|
return withPrefix(path, getGlobalPathPrefix());
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
function absolutify(path, current) {
|
|
73
|
-
// If it's already absolute, return as-is
|
|
74
|
-
if (isAbsolutePath(path)) {
|
|
75
|
-
return path;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (0, _utils.resolve)(path, current);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var rewriteLinkPath = function rewriteLinkPath(path, relativeTo) {
|
|
82
|
-
if (typeof path === "number") {
|
|
83
|
-
return path;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!isLocalLink(path)) {
|
|
87
|
-
return path;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return isAbsolutePath(path) ? withPrefix(path) : absolutify(path, relativeTo);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
67
|
var NavLinkPropTypes = {
|
|
94
68
|
activeClassName: _propTypes.default.string,
|
|
95
69
|
activeStyle: _propTypes.default.object,
|
|
@@ -168,7 +142,7 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
|
|
|
168
142
|
currentPath = this.props._location.pathname + this.props._location.search;
|
|
169
143
|
}
|
|
170
144
|
|
|
171
|
-
var rewrittenPath = rewriteLinkPath(this.props.to, currentPath);
|
|
145
|
+
var rewrittenPath = (0, _rewriteLinkPath.rewriteLinkPath)(this.props.to, currentPath);
|
|
172
146
|
var parsed = (0, _parsePath.parsePath)(rewrittenPath);
|
|
173
147
|
var newPathName = parsed.pathname + parsed.search; // Prefetch is used to speed up next navigations. When you use it on the current navigation,
|
|
174
148
|
// there could be a race-condition where Chrome uses the stale data instead of waiting for the network to complete
|
|
@@ -238,13 +212,13 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
|
|
|
238
212
|
_location = _this$props._location,
|
|
239
213
|
rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props, _excluded);
|
|
240
214
|
|
|
241
|
-
if (process.env.NODE_ENV !== "production" && !isLocalLink(to)) {
|
|
215
|
+
if (process.env.NODE_ENV !== "production" && !(0, _isLocalLink.isLocalLink)(to)) {
|
|
242
216
|
console.warn("External link " + to + " was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links");
|
|
243
217
|
}
|
|
244
218
|
|
|
245
|
-
var prefixedTo = rewriteLinkPath(to, _location.pathname);
|
|
219
|
+
var prefixedTo = (0, _rewriteLinkPath.rewriteLinkPath)(to, _location.pathname);
|
|
246
220
|
|
|
247
|
-
if (!isLocalLink(prefixedTo)) {
|
|
221
|
+
if (!(0, _isLocalLink.isLocalLink)(prefixedTo)) {
|
|
248
222
|
return /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
|
|
249
223
|
href: prefixedTo
|
|
250
224
|
}, rest));
|
|
@@ -315,7 +289,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
315
289
|
exports.default = _default;
|
|
316
290
|
|
|
317
291
|
var navigate = function navigate(to, options) {
|
|
318
|
-
window.___navigate(rewriteLinkPath(to, window.location.pathname), options);
|
|
292
|
+
window.___navigate((0, _rewriteLinkPath.rewriteLinkPath)(to, window.location.pathname), options);
|
|
319
293
|
};
|
|
320
294
|
|
|
321
295
|
exports.navigate = navigate;
|
package/is-local-link.js
CHANGED
|
@@ -11,7 +11,8 @@ var isAbsolute = function isAbsolute(path) {
|
|
|
11
11
|
|
|
12
12
|
var isLocalLink = function isLocalLink(path) {
|
|
13
13
|
if (typeof path !== "string") {
|
|
14
|
-
|
|
14
|
+
return undefined; // TODO(v5): Re-Add TypeError
|
|
15
|
+
// throw new TypeError(`Expected a \`string\`, got \`${typeof path}\``)
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
return !isAbsolute(path);
|
package/package.json
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-link",
|
|
3
3
|
"description": "An enhanced Link component for Gatsby sites with support for resource prefetching",
|
|
4
|
-
"version": "4.7.
|
|
4
|
+
"version": "4.7.1",
|
|
5
5
|
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/gatsbyjs/gatsby/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@babel/runtime": "^7.15.4",
|
|
11
|
-
"@types/reach__router": "^1.3.
|
|
11
|
+
"@types/reach__router": "^1.3.10",
|
|
12
|
+
"gatsby-page-utils": "^2.7.0",
|
|
12
13
|
"prop-types": "^15.7.2"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"@babel/cli": "^7.15.4",
|
|
16
17
|
"@babel/core": "^7.15.5",
|
|
17
18
|
"@testing-library/react": "^11.2.7",
|
|
18
|
-
"babel-preset-gatsby-package": "^2.7.0
|
|
19
|
+
"babel-preset-gatsby-package": "^2.7.0",
|
|
19
20
|
"cross-env": "^7.0.3"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"engines": {
|
|
44
45
|
"node": ">=14.15.0"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f672a67d65176c8e3e624ae0ad797bf5ab7b3263"
|
|
47
48
|
}
|
package/rewrite-link-path.js
CHANGED
|
@@ -19,7 +19,7 @@ var isAbsolutePath = function isAbsolutePath(path) {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
var getGlobalTrailingSlash = function getGlobalTrailingSlash() {
|
|
22
|
-
return
|
|
22
|
+
return typeof __TRAILING_SLASH__ !== "undefined" ? __TRAILING_SLASH__ : undefined;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
function absolutify(path, current) {
|