gatsby-link 2.4.12 → 2.4.16

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/index.js +18 -4
  3. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
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
+ ## [2.4.16](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.15...gatsby-link@2.4.16) (2020-10-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **deps:** update minor and patch for gatsby-link ([#27118](https://github.com/gatsbyjs/gatsby/issues/27118)) ([fc3b2d6](https://github.com/gatsbyjs/gatsby/commit/fc3b2d6cf6f85fd9a933bf850ff5970eb05234d9))
11
+
12
+ ## [2.4.15](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.14...gatsby-link@2.4.15) (2020-09-28)
13
+
14
+ **Note:** Version bump only for package gatsby-link
15
+
16
+ ## [2.4.14](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.13...gatsby-link@2.4.14) (2020-09-15)
17
+
18
+ **Note:** Version bump only for package gatsby-link
19
+
20
+ ## [2.4.13](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.12...gatsby-link@2.4.13) (2020-07-15)
21
+
22
+ ### Bug Fixes
23
+
24
+ - **gatsby:** Support numbers in navigate function ([#25611](https://github.com/gatsbyjs/gatsby/issues/25611)) ([83926c8](https://github.com/gatsbyjs/gatsby/commit/83926c8))
25
+ - **gatsby-link:** Do not crash in unit tests when globals are undefined ([#25608](https://github.com/gatsbyjs/gatsby/issues/25608)) ([6404fc7](https://github.com/gatsbyjs/gatsby/commit/6404fc7))
26
+
6
27
  ## [2.4.12](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.11...gatsby-link@2.4.12) (2020-07-09)
7
28
 
8
29
  **Note:** Version bump only for package gatsby-link
package/index.js CHANGED
@@ -35,7 +35,7 @@ function withPrefix(path, prefix) {
35
35
  var _ref, _prefix;
36
36
 
37
37
  if (prefix === void 0) {
38
- prefix = __BASE_PATH__;
38
+ prefix = getGlobalBasePrefix();
39
39
  }
40
40
 
41
41
  if (!isLocalLink(path)) {
@@ -46,16 +46,26 @@ function withPrefix(path, prefix) {
46
46
  return path;
47
47
  }
48
48
 
49
- var base = (_ref = (_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : __PATH_PREFIX__) !== null && _ref !== void 0 ? _ref : "/";
49
+ var base = (_ref = (_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : getGlobalPathPrefix()) !== null && _ref !== void 0 ? _ref : "/";
50
50
  return "" + ((base === null || base === void 0 ? void 0 : base.endsWith("/")) ? base.slice(0, -1) : base) + (path.startsWith("/") ? path : "/" + path);
51
- }
51
+ } // These global values are wrapped in typeof clauses to ensure the values exist.
52
+ // This is especially problematic in unit testing of this component.
53
+
54
+
55
+ var getGlobalPathPrefix = function getGlobalPathPrefix() {
56
+ return process.env.NODE_ENV !== "production" ? typeof __PATH_PREFIX__ !== "undefined" ? __PATH_PREFIX__ : undefined : __PATH_PREFIX__;
57
+ };
58
+
59
+ var getGlobalBasePrefix = function getGlobalBasePrefix() {
60
+ return process.env.NODE_ENV !== "production" ? typeof __BASE_PATH__ !== "undefined" ? __BASE_PATH__ : undefined : __BASE_PATH__;
61
+ };
52
62
 
53
63
  var isLocalLink = function isLocalLink(path) {
54
64
  return path && !path.startsWith("http://") && !path.startsWith("https://") && !path.startsWith("//");
55
65
  };
56
66
 
57
67
  function withAssetPrefix(path) {
58
- return withPrefix(path, __PATH_PREFIX__);
68
+ return withPrefix(path, getGlobalPathPrefix());
59
69
  }
60
70
 
61
71
  function absolutify(path, current) {
@@ -68,6 +78,10 @@ function absolutify(path, current) {
68
78
  }
69
79
 
70
80
  var rewriteLinkPath = function rewriteLinkPath(path, relativeTo) {
81
+ if (typeof path === "number") {
82
+ return path;
83
+ }
84
+
71
85
  if (!isLocalLink(path)) {
72
86
  return path;
73
87
  }
package/package.json CHANGED
@@ -1,22 +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": "2.4.12",
4
+ "version": "2.4.16",
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
- "@babel/runtime": "^7.10.3",
11
- "@types/reach__router": "^1.3.3",
10
+ "@babel/runtime": "^7.11.2",
11
+ "@types/reach__router": "^1.3.6",
12
12
  "prop-types": "^15.7.2"
13
13
  },
14
14
  "devDependencies": {
15
- "@babel/cli": "^7.10.3",
16
- "@babel/core": "^7.10.3",
15
+ "@babel/cli": "^7.11.6",
16
+ "@babel/core": "^7.11.6",
17
17
  "@testing-library/react": "^9.5.0",
18
- "babel-preset-gatsby-package": "^0.5.2",
19
- "cross-env": "^5.2.1"
18
+ "babel-preset-gatsby-package": "^0.5.3",
19
+ "cross-env": "^7.0.2"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@reach/router": "^1.3.3",
@@ -43,5 +43,5 @@
43
43
  "engines": {
44
44
  "node": ">=10.13.0"
45
45
  },
46
- "gitHead": "960d523861b855c1fea45ceefe9cd01db760995b"
46
+ "gitHead": "c0668d4ef25dab4ac43bc3bf1064c95132c5a059"
47
47
  }