getRelativePath

获取两个 URL 之间的相对路径

用法

getRelativePath 函数用于获取两个 URL 之间的相对路径。

import { getRelativePath } from '@movk/core'

getRelativePath('https://example.com/a/b', 'https://example.com/a/c')
// '../c'

getRelativePath('https://example.com/a', 'https://example.com/a/b/c')
// 'b/c'

API

getRelativePath(from, to)

获取两个 URL 之间的相对路径。

参数

from
string required
起始 URL。
to
string required
目标 URL。

返回值

返回值
string
相对路径。

Changelog

7c832 — refactor!: 重构模块架构,拆分 utils 为专业化模块

Copyright © 2024 - 2026 YiXuan - MIT License