vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.01k stars 2.1k forks source link

base配置打包之后少了斜杠,变成https:/www.baidu.com/logo.svg #4095

Closed chenyulun closed 3 months ago

chenyulun commented 3 months ago

Describe the bug

构建之后有些http://变成了http:/少了一个斜杠

image

Reproduction

export default defineConfig({
  base: 'https://www.baidu.com/',
  // ...
  })
  ```md
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home

hero:
  name: "PUI前端知识库"
  text: "提供前端生态工具和解决方案"
  tagline: 让开发变得更简单
  image:
    src: /logo.svg
    alt: PUI
  actions:
    - theme: brand
      text: 开发指南
      link: /guide
    - theme: alt
      text: API
      link: /api

features:
  - title: PUI组件
    details: 提供银行通用的移动端UI组件库
  - title: 脚手架
    details: 提供银行通用的移动端脚手架
  - title: 工具库
    details: 提供银行通用的工具库
---

Expected behavior

期望能正确处理base

System Info

System:
    OS: macOS 12.6.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 17.04 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/Library/Caches/fnm_multishells/29829_1722424042245/bin/node
    Yarn: 1.22.22 - ~/Library/pnpm/yarn
    npm: 9.8.1 - ~/Library/Caches/fnm_multishells/29829_1722424042245/bin/npm
    pnpm: 9.6.0 - ~/Library/pnpm/pnpm
    bun: 1.0.29 - ~/.bun/bin/bun
    Watchman: 2023.10.09.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 127.0.6533.72
    Chrome Canary: 129.0.6626.0
    Edge: 127.0.2651.74
    Safari: 16.1

Additional context

{
  "name": "knowledge-docs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "docs:dev": "vitepress dev docs",
    "docs:build": "vitepress build docs",
    "docs:preview": "vitepress preview docs"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "vitepress": "^1.3.1"
  }
}

Validations

brc-dd commented 3 months ago

base is not meant for those cases. It is needed if you're deploying to a subpath.

if you're deploying to https://some-domain.com/ -- remove base if you're deploying to https://some-domain.com/some-path/ -- set base to /some-path/

chenyulun commented 3 months ago

These 2 places don't agree, and that's a problem, is it simply replacing the double slash to become a single slash? @brc-dd

brc-dd commented 3 months ago

Absolute URLs are not supported in base and don't mean anything. It's garbage in, garbage out.

chenyulun commented 3 months ago

ok! tks!