Skip to content

规范化 URL 实现 #2

@lzxb

Description

@lzxb

RouterOptions.base

base 是路由的基础路径配置项,用于指定路由的前缀路径。

类型定义:

type BASE = string;
  • 接受一个 string

默认值:

  • 浏览器环境:new URL(location.href)
  • 服务端环境:new URL('http://localhost')

router.push(pushUrl)

URL 解析遵循以下优先级顺序:

  1. 绝对地址

    • 直接使用 new URL(pushUrl) 解析
    • 示例:https://example.com/path
  2. 包含域名的相对地址

    • 使用 new URL(normalizeUrl(pushUrl)) 解析
    • 示例://example.com/path
  3. 站内相对地址

    • 使用 new URL(pushUrl, base) 解析
    • 示例:path/to/page

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions