dumi 2.1.7 → 2.1.8

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.
@@ -225,6 +225,8 @@ export var useSidebarData = function useSidebarData() {
225
225
  // /en-US/a/b => /en-US/a
226
226
  // /en-US/a/b/ => /en-US/a (also strip trailing /)
227
227
 
228
- var parentPath = clearPath ? pathname.replace(/(\/[^/]+)(\/[^/]+\/?)$/, '$1') : pathname;
228
+ var parentPath = clearPath ? pathname.replace(clearPath, function (s) {
229
+ return s.replace(/([^/]+)(\/[^/]+\/?)$/, '$1');
230
+ }) : pathname;
229
231
  return parentPath ? sidebar[parentPath] : [];
230
232
  };
@@ -31,7 +31,7 @@ var visit;
31
31
  ({ visit } = await import("unist-util-visit"));
32
32
  })();
33
33
  function isRelativeUrl(url) {
34
- return !/^((blob:)?\w+:)?\/\//.test(url) && !import_path.default.isAbsolute(url);
34
+ return !url.startsWith("data:image") && !/^((blob:)?\w+:)?\/\//.test(url) && !import_path.default.isAbsolute(url);
35
35
  }
36
36
  function rehypeImg() {
37
37
  return (tree) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -19,7 +19,8 @@ function getTargetLocalePath(_ref) {
19
19
  var pathname = _ref.pathname,
20
20
  current = _ref.current,
21
21
  target = _ref.target;
22
- var clearPath = 'base' in current ? pathname.replace(current.base.replace(/\/$/, ''), '') : pathname.replace(new RegExp("".concat(current.suffix, "$")), '');
22
+ var clearPath = 'base' in current ? // handle '/en-US/a' => '/a' or '/en-US' => '' => '/'
23
+ pathname.replace(current.base.replace(/\/$/, ''), '') || '/' : pathname.replace(new RegExp("".concat(current.suffix, "$")), '');
23
24
  return 'base' in target ? "".concat( // for `/` base, strip duplicated leading slash
24
25
  target.base.replace(/\/$/, '')).concat(clearPath) // for `/` clearPath, strip duplicated ending slash
25
26
  .replace(/([^/])\/$/, '$1') : "".concat(clearPath).concat(target.suffix);