gatsby-link 4.18.0-next.0 → 4.18.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/.babelrc CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "presets": [["babel-preset-gatsby-package", { "browser": true }]]
2
+ "presets": [["babel-preset-gatsby-package", { "browser": true, "esm": true }]]
3
3
  }
package/index.js CHANGED
@@ -1,78 +1,45 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.navigate = exports.default = void 0;
7
- exports.withAssetPrefix = withAssetPrefix;
8
- exports.withPrefix = withPrefix;
9
-
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
-
12
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
-
14
- var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
15
-
16
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
17
-
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
-
20
- var _react = _interopRequireDefault(require("react"));
21
-
22
- var _reachRouter = require("@gatsbyjs/reach-router");
23
-
24
- var _parsePath = require("./parse-path");
25
-
26
- exports.parsePath = _parsePath.parsePath;
27
-
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"];
33
-
34
- function withPrefix(path, prefix) {
35
- var _ref, _prefix;
36
-
37
- if (prefix === void 0) {
38
- prefix = getGlobalBasePrefix();
39
- }
40
-
41
- if (!(0, _isLocalLink.isLocalLink)(path)) {
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ const _excluded = ["to", "getProps", "onClick", "onMouseEnter", "activeClassName", "activeStyle", "innerRef", "partiallyActive", "state", "replace", "_location"];
4
+ import PropTypes from "prop-types";
5
+ import React from "react";
6
+ import { Link, Location } from "@gatsbyjs/reach-router";
7
+ import { parsePath } from "./parse-path";
8
+ import { isLocalLink } from "./is-local-link";
9
+ import { rewriteLinkPath } from "./rewrite-link-path";
10
+ export { parsePath };
11
+ export function withPrefix(path, prefix = getGlobalBasePrefix()) {
12
+ var _ref;
13
+
14
+ if (!isLocalLink(path)) {
42
15
  return path;
43
16
  }
44
17
 
45
- if (path.startsWith("./") || path.startsWith("../")) {
18
+ if (path.startsWith(`./`) || path.startsWith(`../`)) {
46
19
  return path;
47
20
  }
48
21
 
49
- var base = (_ref = (_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : getGlobalPathPrefix()) !== null && _ref !== void 0 ? _ref : "/";
50
- return "" + (base !== null && base !== void 0 && base.endsWith("/") ? base.slice(0, -1) : base) + (path.startsWith("/") ? path : "/" + path);
22
+ const base = (_ref = prefix !== null && prefix !== void 0 ? prefix : getGlobalPathPrefix()) !== null && _ref !== void 0 ? _ref : `/`;
23
+ return `${base !== null && base !== void 0 && base.endsWith(`/`) ? base.slice(0, -1) : base}${path.startsWith(`/`) ? path : `/${path}`}`;
51
24
  } // These global values are wrapped in typeof clauses to ensure the values exist.
52
25
  // This is especially problematic in unit testing of this component.
53
26
 
27
+ const getGlobalPathPrefix = () => process.env.NODE_ENV !== `production` ? typeof __PATH_PREFIX__ !== `undefined` ? __PATH_PREFIX__ : undefined : __PATH_PREFIX__;
54
28
 
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
- };
29
+ const getGlobalBasePrefix = () => process.env.NODE_ENV !== `production` ? typeof __BASE_PATH__ !== `undefined` ? __BASE_PATH__ : undefined : __BASE_PATH__;
62
30
 
63
- function withAssetPrefix(path) {
31
+ export function withAssetPrefix(path) {
64
32
  return withPrefix(path, getGlobalPathPrefix());
65
33
  }
66
-
67
- var NavLinkPropTypes = {
68
- activeClassName: _propTypes.default.string,
69
- activeStyle: _propTypes.default.object,
70
- partiallyActive: _propTypes.default.bool
34
+ const NavLinkPropTypes = {
35
+ activeClassName: PropTypes.string,
36
+ activeStyle: PropTypes.object,
37
+ partiallyActive: PropTypes.bool
71
38
  }; // Set up IntersectionObserver
72
39
 
73
- var createIntersectionObserver = function createIntersectionObserver(el, cb) {
74
- var io = new window.IntersectionObserver(function (entries) {
75
- entries.forEach(function (entry) {
40
+ const createIntersectionObserver = (el, cb) => {
41
+ const io = new window.IntersectionObserver(entries => {
42
+ entries.forEach(entry => {
76
43
  if (el === entry.target) {
77
44
  // Check if element is within viewport, remove listener, destroy observer, and run link callback.
78
45
  // MSEdge doesn't currently support isIntersecting, so also test for an intersectionRatio > 0
@@ -84,67 +51,59 @@ var createIntersectionObserver = function createIntersectionObserver(el, cb) {
84
51
  io.observe(el);
85
52
  return {
86
53
  instance: io,
87
- el: el
54
+ el
88
55
  };
89
56
  };
90
57
 
91
58
  function GatsbyLinkLocationWrapper(props) {
92
- return /*#__PURE__*/_react.default.createElement(_reachRouter.Location, null, function (_ref2) {
93
- var location = _ref2.location;
94
- return /*#__PURE__*/_react.default.createElement(GatsbyLink, (0, _extends2.default)({}, props, {
95
- _location: location
96
- }));
97
- });
59
+ return /*#__PURE__*/React.createElement(Location, null, ({
60
+ location
61
+ }) => /*#__PURE__*/React.createElement(GatsbyLink, _extends({}, props, {
62
+ _location: location
63
+ })));
98
64
  }
99
65
 
100
- var GatsbyLink = /*#__PURE__*/function (_React$Component) {
101
- (0, _inheritsLoose2.default)(GatsbyLink, _React$Component);
102
-
103
- function GatsbyLink(props) {
104
- var _this;
105
-
106
- _this = _React$Component.call(this, props) || this; // Default to no support for IntersectionObserver
66
+ class GatsbyLink extends React.Component {
67
+ constructor(props) {
68
+ super(props); // Default to no support for IntersectionObserver
107
69
 
108
- _this.defaultGetProps = function (_ref3) {
109
- var isPartiallyCurrent = _ref3.isPartiallyCurrent,
110
- isCurrent = _ref3.isCurrent;
111
-
112
- if (_this.props.partiallyActive ? isPartiallyCurrent : isCurrent) {
70
+ this.defaultGetProps = ({
71
+ isPartiallyCurrent,
72
+ isCurrent
73
+ }) => {
74
+ if (this.props.partiallyActive ? isPartiallyCurrent : isCurrent) {
113
75
  return {
114
- className: [_this.props.className, _this.props.activeClassName].filter(Boolean).join(" "),
115
- style: (0, _extends2.default)({}, _this.props.style, _this.props.activeStyle)
76
+ className: [this.props.className, this.props.activeClassName].filter(Boolean).join(` `),
77
+ style: _extends({}, this.props.style, this.props.activeStyle)
116
78
  };
117
79
  }
118
80
 
119
81
  return null;
120
82
  };
121
83
 
122
- var IOSupported = false;
84
+ let IOSupported = false;
123
85
 
124
- if (typeof window !== "undefined" && window.IntersectionObserver) {
86
+ if (typeof window !== `undefined` && window.IntersectionObserver) {
125
87
  IOSupported = true;
126
88
  }
127
89
 
128
- _this.state = {
129
- IOSupported: IOSupported
90
+ this.state = {
91
+ IOSupported
130
92
  };
131
- _this.abortPrefetch = null;
132
- _this.handleRef = _this.handleRef.bind((0, _assertThisInitialized2.default)(_this));
133
- return _this;
93
+ this.abortPrefetch = null;
94
+ this.handleRef = this.handleRef.bind(this);
134
95
  }
135
96
 
136
- var _proto = GatsbyLink.prototype;
137
-
138
- _proto._prefetch = function _prefetch() {
139
- var currentPath = window.location.pathname + window.location.search; // reach router should have the correct state
97
+ _prefetch() {
98
+ let currentPath = window.location.pathname + window.location.search; // reach router should have the correct state
140
99
 
141
100
  if (this.props._location && this.props._location.pathname) {
142
101
  currentPath = this.props._location.pathname + this.props._location.search;
143
102
  }
144
103
 
145
- var rewrittenPath = (0, _rewriteLinkPath.rewriteLinkPath)(this.props.to, currentPath);
146
- var parsed = (0, _parsePath.parsePath)(rewrittenPath);
147
- var newPathName = parsed.pathname + parsed.search; // Prefetch is used to speed up next navigations. When you use it on the current navigation,
104
+ const rewrittenPath = rewriteLinkPath(this.props.to, currentPath);
105
+ const parsed = parsePath(rewrittenPath);
106
+ const newPathName = parsed.pathname + parsed.search; // Prefetch is used to speed up next navigations. When you use it on the current navigation,
148
107
  // there could be a race-condition where Chrome uses the stale data instead of waiting for the network to complete
149
108
 
150
109
  if (currentPath !== newPathName) {
@@ -152,16 +111,17 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
152
111
  }
153
112
 
154
113
  return undefined;
155
- };
114
+ }
156
115
 
157
- _proto.componentWillUnmount = function componentWillUnmount() {
116
+ componentWillUnmount() {
158
117
  if (!this.io) {
159
118
  return;
160
119
  }
161
120
 
162
- var _this$io = this.io,
163
- instance = _this$io.instance,
164
- el = _this$io.el;
121
+ const {
122
+ instance,
123
+ el
124
+ } = this.io;
165
125
 
166
126
  if (this.abortPrefetch) {
167
127
  this.abortPrefetch.abort();
@@ -169,12 +129,10 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
169
129
 
170
130
  instance.unobserve(el);
171
131
  instance.disconnect();
172
- };
173
-
174
- _proto.handleRef = function handleRef(ref) {
175
- var _this2 = this;
132
+ }
176
133
 
177
- if (this.props.innerRef && Object.prototype.hasOwnProperty.call(this.props.innerRef, "current")) {
134
+ handleRef(ref) {
135
+ if (this.props.innerRef && Object.prototype.hasOwnProperty.call(this.props.innerRef, `current`)) {
178
136
  this.props.innerRef.current = ref;
179
137
  } else if (this.props.innerRef) {
180
138
  this.props.innerRef(ref);
@@ -182,85 +140,80 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
182
140
 
183
141
  if (this.state.IOSupported && ref) {
184
142
  // If IO supported and element reference found, setup Observer functionality
185
- this.io = createIntersectionObserver(ref, function (inViewPort) {
143
+ this.io = createIntersectionObserver(ref, inViewPort => {
186
144
  if (inViewPort) {
187
- _this2.abortPrefetch = _this2._prefetch();
145
+ this.abortPrefetch = this._prefetch();
188
146
  } else {
189
- if (_this2.abortPrefetch) {
190
- _this2.abortPrefetch.abort();
147
+ if (this.abortPrefetch) {
148
+ this.abortPrefetch.abort();
191
149
  }
192
150
  }
193
151
  });
194
152
  }
195
- };
153
+ }
196
154
 
197
- _proto.render = function render() {
198
- var _this3 = this;
199
-
200
- var _this$props = this.props,
201
- to = _this$props.to,
202
- _this$props$getProps = _this$props.getProps,
203
- getProps = _this$props$getProps === void 0 ? this.defaultGetProps : _this$props$getProps,
204
- _onClick = _this$props.onClick,
205
- _onMouseEnter = _this$props.onMouseEnter,
206
- $activeClassName = _this$props.activeClassName,
207
- $activeStyle = _this$props.activeStyle,
208
- $innerRef = _this$props.innerRef,
209
- partiallyActive = _this$props.partiallyActive,
210
- state = _this$props.state,
211
- replace = _this$props.replace,
212
- _location = _this$props._location,
213
- rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props, _excluded);
214
-
215
- if (process.env.NODE_ENV !== "production" && !(0, _isLocalLink.isLocalLink)(to)) {
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");
155
+ render() {
156
+ const _this$props = this.props,
157
+ {
158
+ to,
159
+ getProps = this.defaultGetProps,
160
+ onClick,
161
+ onMouseEnter,
162
+ state,
163
+ replace,
164
+ _location
165
+ } = _this$props,
166
+ rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
167
+
168
+ if (process.env.NODE_ENV !== `production` && !isLocalLink(to)) {
169
+ 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`);
217
170
  }
218
171
 
219
- var prefixedTo = (0, _rewriteLinkPath.rewriteLinkPath)(to, _location.pathname);
172
+ const prefixedTo = rewriteLinkPath(to, _location.pathname);
220
173
 
221
- if (!(0, _isLocalLink.isLocalLink)(prefixedTo)) {
222
- return /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
174
+ if (!isLocalLink(prefixedTo)) {
175
+ return /*#__PURE__*/React.createElement("a", _extends({
223
176
  href: prefixedTo
224
177
  }, rest));
225
178
  }
226
179
 
227
- return /*#__PURE__*/_react.default.createElement(_reachRouter.Link, (0, _extends2.default)({
180
+ return /*#__PURE__*/React.createElement(Link, _extends({
228
181
  to: prefixedTo,
229
182
  state: state,
230
183
  getProps: getProps,
231
184
  innerRef: this.handleRef,
232
- onMouseEnter: function onMouseEnter(e) {
233
- if (_onMouseEnter) {
234
- _onMouseEnter(e);
185
+ onMouseEnter: e => {
186
+ if (onMouseEnter) {
187
+ onMouseEnter(e);
235
188
  }
236
189
 
237
- var parsed = (0, _parsePath.parsePath)(prefixedTo);
190
+ const parsed = parsePath(prefixedTo);
238
191
 
239
192
  ___loader.hovering(parsed.pathname + parsed.search);
240
193
  },
241
- onClick: function onClick(e) {
242
- if (_onClick) {
243
- _onClick(e);
194
+ onClick: e => {
195
+ if (onClick) {
196
+ onClick(e);
244
197
  }
245
198
 
246
199
  if (e.button === 0 && // ignore right clicks
247
- !_this3.props.target && // let browser handle "target=_blank"
200
+ !this.props.target && // let browser handle "target=_blank"
248
201
  !e.defaultPrevented && // onClick prevented default
249
202
  !e.metaKey && // ignore clicks with modifier keys...
250
203
  !e.altKey && !e.ctrlKey && !e.shiftKey) {
251
204
  e.preventDefault();
252
- var shouldReplace = replace;
205
+ let shouldReplace = replace;
253
206
 
254
- var isCurrent = encodeURI(prefixedTo) === _location.pathname;
207
+ const isCurrent = encodeURI(prefixedTo) === _location.pathname;
255
208
 
256
- if (typeof replace !== "boolean" && isCurrent) {
209
+ if (typeof replace !== `boolean` && isCurrent) {
257
210
  shouldReplace = true;
258
211
  } // Make sure the necessary scripts and data are
259
212
  // loaded before continuing.
260
213
 
261
214
 
262
215
  window.___navigate(prefixedTo, {
263
- state: state,
216
+ state,
264
217
  replace: shouldReplace
265
218
  });
266
219
  }
@@ -268,28 +221,19 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
268
221
  return true;
269
222
  }
270
223
  }, rest));
271
- };
272
-
273
- return GatsbyLink;
274
- }(_react.default.Component);
224
+ }
275
225
 
276
- GatsbyLink.propTypes = (0, _extends2.default)({}, NavLinkPropTypes, {
277
- onClick: _propTypes.default.func,
278
- to: _propTypes.default.string.isRequired,
279
- replace: _propTypes.default.bool,
280
- state: _propTypes.default.object
281
- });
226
+ }
282
227
 
283
- var _default = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
284
- return /*#__PURE__*/_react.default.createElement(GatsbyLinkLocationWrapper, (0, _extends2.default)({
285
- innerRef: ref
286
- }, props));
228
+ GatsbyLink.propTypes = _extends({}, NavLinkPropTypes, {
229
+ onClick: PropTypes.func,
230
+ to: PropTypes.string.isRequired,
231
+ replace: PropTypes.bool,
232
+ state: PropTypes.object
287
233
  });
288
-
289
- exports.default = _default;
290
-
291
- var navigate = function navigate(to, options) {
292
- window.___navigate((0, _rewriteLinkPath.rewriteLinkPath)(to, window.location.pathname), options);
293
- };
294
-
295
- exports.navigate = navigate;
234
+ export default /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(GatsbyLinkLocationWrapper, _extends({
235
+ innerRef: ref
236
+ }, props)));
237
+ export const navigate = (to, options) => {
238
+ window.___navigate(rewriteLinkPath(to, window.location.pathname), options);
239
+ };
package/is-local-link.js CHANGED
@@ -1,21 +1,13 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.isLocalLink = void 0;
5
1
  // Copied from https://github.com/sindresorhus/is-absolute-url/blob/3ab19cc2e599a03ea691bcb8a4c09fa3ebb5da4f/index.js
6
- var ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
2
+ const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
7
3
 
8
- var isAbsolute = function isAbsolute(path) {
9
- return ABSOLUTE_URL_REGEX.test(path);
10
- };
4
+ const isAbsolute = path => ABSOLUTE_URL_REGEX.test(path);
11
5
 
12
- var isLocalLink = function isLocalLink(path) {
13
- if (typeof path !== "string") {
6
+ export const isLocalLink = path => {
7
+ if (typeof path !== `string`) {
14
8
  return undefined; // TODO(v5): Re-Add TypeError
15
9
  // throw new TypeError(`Expected a \`string\`, got \`${typeof path}\``)
16
10
  }
17
11
 
18
12
  return !isAbsolute(path);
19
- };
20
-
21
- exports.isLocalLink = isLocalLink;
13
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.18.0-next.0",
4
+ "version": "4.18.1",
5
5
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/gatsbyjs/gatsby/issues"
@@ -9,14 +9,14 @@
9
9
  "dependencies": {
10
10
  "@babel/runtime": "^7.15.4",
11
11
  "@types/reach__router": "^1.3.10",
12
- "gatsby-page-utils": "^2.18.0-next.0",
12
+ "gatsby-page-utils": "^2.18.1",
13
13
  "prop-types": "^15.8.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@babel/cli": "^7.15.4",
17
17
  "@babel/core": "^7.15.5",
18
18
  "@testing-library/react": "^11.2.7",
19
- "babel-preset-gatsby-package": "^2.18.0-next.0",
19
+ "babel-preset-gatsby-package": "^2.18.0",
20
20
  "cross-env": "^7.0.3"
21
21
  },
22
22
  "peerDependencies": {
@@ -44,5 +44,5 @@
44
44
  "engines": {
45
45
  "node": ">=14.15.0"
46
46
  },
47
- "gitHead": "e7136908e238d1bc6c3d66c306533c81394535ea"
47
+ "gitHead": "c6aa79d485c32ed81f22ec056669e8cd1766dd62"
48
48
  }
package/parse-path.js CHANGED
@@ -1,20 +1,15 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.parsePath = parsePath;
5
-
6
- function parsePath(path) {
7
- var pathname = path || "/";
8
- var search = "";
9
- var hash = "";
10
- var hashIndex = pathname.indexOf("#");
1
+ export function parsePath(path) {
2
+ let pathname = path || `/`;
3
+ let search = ``;
4
+ let hash = ``;
5
+ const hashIndex = pathname.indexOf(`#`);
11
6
 
12
7
  if (hashIndex !== -1) {
13
8
  hash = pathname.slice(hashIndex);
14
9
  pathname = pathname.slice(0, hashIndex);
15
10
  }
16
11
 
17
- var searchIndex = pathname.indexOf("?");
12
+ const searchIndex = pathname.indexOf(`?`);
18
13
 
19
14
  if (searchIndex !== -1) {
20
15
  search = pathname.slice(searchIndex);
@@ -23,7 +18,7 @@ function parsePath(path) {
23
18
 
24
19
  return {
25
20
  pathname: pathname,
26
- search: search === "?" ? "" : search,
27
- hash: hash === "#" ? "" : hash
21
+ search: search === `?` ? `` : search,
22
+ hash: hash === `#` ? `` : hash
28
23
  };
29
24
  }
@@ -1,26 +1,13 @@
1
- "use strict";
1
+ import { resolve } from "@gatsbyjs/reach-router/lib/utils"; // Specific import to treeshake Node.js stuff
2
2
 
3
- exports.__esModule = true;
4
- exports.rewriteLinkPath = void 0;
3
+ import { applyTrailingSlashOption } from "gatsby-page-utils/apply-trailing-slash-option";
4
+ import { parsePath } from "./parse-path";
5
+ import { isLocalLink } from "./is-local-link";
6
+ import { withPrefix } from ".";
5
7
 
6
- var _utils = require("@gatsbyjs/reach-router/lib/utils");
8
+ const isAbsolutePath = path => path === null || path === void 0 ? void 0 : path.startsWith(`/`);
7
9
 
8
- var _applyTrailingSlashOption = require("gatsby-page-utils/apply-trailing-slash-option");
9
-
10
- var _parsePath2 = require("./parse-path");
11
-
12
- var _isLocalLink = require("./is-local-link");
13
-
14
- var _ = require(".");
15
-
16
- // Specific import to treeshake Node.js stuff
17
- var isAbsolutePath = function isAbsolutePath(path) {
18
- return path === null || path === void 0 ? void 0 : path.startsWith("/");
19
- };
20
-
21
- var getGlobalTrailingSlash = function getGlobalTrailingSlash() {
22
- return typeof __TRAILING_SLASH__ !== "undefined" ? __TRAILING_SLASH__ : undefined;
23
- };
10
+ const getGlobalTrailingSlash = () => typeof __TRAILING_SLASH__ !== `undefined` ? __TRAILING_SLASH__ : undefined;
24
11
 
25
12
  function absolutify(path, current) {
26
13
  // If it's already absolute, return as-is
@@ -28,39 +15,37 @@ function absolutify(path, current) {
28
15
  return path;
29
16
  }
30
17
 
31
- var option = getGlobalTrailingSlash();
32
- var absolutePath = (0, _utils.resolve)(path, current);
18
+ const option = getGlobalTrailingSlash();
19
+ const absolutePath = resolve(path, current);
33
20
 
34
- if (option === "always" || option === "never") {
35
- return (0, _applyTrailingSlashOption.applyTrailingSlashOption)(absolutePath, option);
21
+ if (option === `always` || option === `never`) {
22
+ return applyTrailingSlashOption(absolutePath, option);
36
23
  }
37
24
 
38
25
  return absolutePath;
39
26
  }
40
27
 
41
- var rewriteLinkPath = function rewriteLinkPath(path, relativeTo) {
42
- if (typeof path === "number") {
28
+ export const rewriteLinkPath = (path, relativeTo) => {
29
+ if (typeof path === `number`) {
43
30
  return path;
44
31
  }
45
32
 
46
- if (!(0, _isLocalLink.isLocalLink)(path)) {
33
+ if (!isLocalLink(path)) {
47
34
  return path;
48
35
  }
49
36
 
50
- var _parsePath = (0, _parsePath2.parsePath)(path),
51
- pathname = _parsePath.pathname,
52
- search = _parsePath.search,
53
- hash = _parsePath.hash;
54
-
55
- var option = getGlobalTrailingSlash();
56
- var adjustedPath = path;
57
-
58
- if (option === "always" || option === "never") {
59
- var output = (0, _applyTrailingSlashOption.applyTrailingSlashOption)(pathname, option);
60
- adjustedPath = "" + output + search + hash;
37
+ const {
38
+ pathname,
39
+ search,
40
+ hash
41
+ } = parsePath(path);
42
+ const option = getGlobalTrailingSlash();
43
+ let adjustedPath = path;
44
+
45
+ if (option === `always` || option === `never`) {
46
+ const output = applyTrailingSlashOption(pathname, option);
47
+ adjustedPath = `${output}${search}${hash}`;
61
48
  }
62
49
 
63
- return isAbsolutePath(adjustedPath) ? (0, _.withPrefix)(adjustedPath) : absolutify(adjustedPath, relativeTo);
64
- };
65
-
66
- exports.rewriteLinkPath = rewriteLinkPath;
50
+ return isAbsolutePath(adjustedPath) ? withPrefix(adjustedPath) : absolutify(adjustedPath, relativeTo);
51
+ };