Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vitejs/vite
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.5.2
Choose a base ref
...
head repository: vitejs/vite
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aac695e9f8f29da43c2f7c50c549fa3d3dfeeadc
Choose a head ref
  • 2 commits
  • 8 files changed
  • 2 contributors

Commits on Mar 24, 2024

  1. Copy the full SHA
    96a7f3a View commit details
  2. release: v4.5.3

    sapphi-red committed Mar 24, 2024
    Copy the full SHA
    aac695e View commit details
6 changes: 6 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## <small>4.5.3 (2024-03-24)</small>

* fix: `fs.deny` with globs with directories (#16250) ([96a7f3a](https://github.com/vitejs/vite/commit/96a7f3a)), closes [#16250](https://github.com/vitejs/vite/issues/16250)



## <small>4.5.2 (2024-01-19)</small>

* fix: fs deny for case insensitive systems (#15653) ([eeec23b](https://github.com/vitejs/vite/commit/eeec23b)), closes [#15653](https://github.com/vitejs/vite/issues/15653)
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "4.5.2",
"version": "4.5.3",
"type": "module",
"license": "MIT",
"author": "Evan You",
17 changes: 13 additions & 4 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
@@ -509,10 +509,19 @@ export async function _createServer(
_importGlobMap: new Map(),
_forceOptimizeOnRestart: false,
_pendingRequests: new Map(),
_fsDenyGlob: picomatch(config.server.fs.deny, {
matchBase: true,
nocase: true,
}),
_fsDenyGlob: picomatch(
// matchBase: true does not work as it's documented
// https://github.com/micromatch/picomatch/issues/89
// convert patterns without `/` on our side for now
config.server.fs.deny.map((pattern) =>
pattern.includes('/') ? pattern : `**/${pattern}`,
),
{
matchBase: false,
nocase: true,
dot: true,
},
),
_shortcutsOptions: undefined,
}

17 changes: 17 additions & 0 deletions playground/fs-serve/__tests__/deny/fs-serve-deny.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, test } from 'vitest'
import { isServe, page, viteTestUrl } from '~utils'

describe.runIf(isServe)('main', () => {
test('**/deny/** should deny src/deny/deny.txt', async () => {
const res = await page.request.fetch(
new URL('/src/deny/deny.txt', viteTestUrl).href,
)
expect(res.status()).toBe(403)
})
test('**/deny/** should deny src/deny/.deny', async () => {
const res = await page.request.fetch(
new URL('/src/deny/.deny', viteTestUrl).href,
)
expect(res.status()).toBe(403)
})
})
5 changes: 4 additions & 1 deletion playground/fs-serve/package.json
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@
"preview": "vite preview root",
"dev:base": "vite root --config ./root/vite.config-base.js",
"build:base": "vite build root --config ./root/vite.config-base.js",
"preview:base": "vite preview root --config ./root/vite.config-base.js"
"preview:base": "vite preview root --config ./root/vite.config-base.js",
"dev:deny": "vite root --config ./root/vite.config-deny.js",
"build:deny": "vite build root --config ./root/vite.config-deny.js",
"preview:deny": "vite preview root --config ./root/vite.config-deny.js"
}
}
1 change: 1 addition & 0 deletions playground/fs-serve/root/src/deny/.deny
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.deny
1 change: 1 addition & 0 deletions playground/fs-serve/root/src/deny/deny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny
22 changes: 22 additions & 0 deletions playground/fs-serve/root/vite.config-deny.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from 'node:path'
import { defineConfig } from 'vite'

export default defineConfig({
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, 'src/index.html'),
},
},
},
server: {
fs: {
strict: true,
allow: [path.resolve(__dirname, 'src')],
deny: ['**/deny/**'],
},
},
define: {
ROOT: JSON.stringify(path.dirname(__dirname).replace(/\\/g, '/')),
},
})