Просмотр исходного кода

use getParentPath from core package

Futa Arai 10 месяцев назад
Родитель
Сommit
7568045f4b
1 измененных файлов с 2 добавлено и 16 удалено
  1. 2 16
      packages/remark-lsx/src/client/utils/page-node.ts

+ 2 - 16
packages/remark-lsx/src/client/utils/page-node.ts

@@ -1,27 +1,13 @@
 import type { IPageHasId } from '@growi/core';
+import { getParentPath as getParentPathCore } from '@growi/core/dist/utils/path-utils';
 import type { ParseRangeResult } from '@growi/core/dist/remark-plugins';
 import { removeTrailingSlash } from '@growi/core/dist/utils/path-utils';
 
 import type { PageNode } from '../../interfaces/page-node';
 import { getDepthOfPath } from '../../utils/depth-utils';
 
-/**
- * Method to replace url.resolve.
- * url.resolve is legacy, use WHATWG URL API instead.
- * c.f) https://nodejs.org/api/url.html#url_url_resolve_from_to
- */
-function resolve(from: string, to: string) {
-  const resolvedUrl = new URL(to, new URL(from, 'resolve://'));
-  if (resolvedUrl.protocol === 'resolve:') {
-    // `from` is a relative URL.
-    const { pathname, search, hash } = resolvedUrl;
-    return pathname + search + hash;
-  }
-  return resolvedUrl.toString();
-}
-
 function getParentPath(path: string) {
-  return removeTrailingSlash(decodeURIComponent(resolve(path, './')));
+  return removeTrailingSlash(decodeURIComponent(getParentPathCore(path)));
 }
 
 /**