File tree 1 file changed +15
-13
lines changed
packages/vite/src/node/server/middlewares
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -114,20 +114,22 @@ export function transformMiddleware(
114
114
}
115
115
}
116
116
117
- const publicPath =
118
- normalizePath ( server . config . publicDir ) . slice (
119
- server . config . root . length
120
- ) + '/'
121
- // warn explicit public paths
122
- if ( url . startsWith ( publicPath ) ) {
123
- logger . warn (
124
- chalk . yellow (
125
- `files in the public directory are served at the root path.\n` +
126
- `Instead of ${ chalk . cyan ( url ) } , use ${ chalk . cyan (
127
- url . replace ( publicPath , '/' )
128
- ) } .`
117
+ // check if public dir is inside root dir
118
+ const publicDir = normalizePath ( server . config . publicDir )
119
+ const rootDir = normalizePath ( server . config . root )
120
+ if ( publicDir . startsWith ( rootDir ) ) {
121
+ const publicPath = `${ publicDir . slice ( rootDir . length ) } /`
122
+ // warn explicit public paths
123
+ if ( url . startsWith ( publicPath ) ) {
124
+ logger . warn (
125
+ chalk . yellow (
126
+ `files in the public directory are served at the root path.\n` +
127
+ `Instead of ${ chalk . cyan ( url ) } , use ${ chalk . cyan (
128
+ url . replace ( publicPath , '/' )
129
+ ) } .`
130
+ )
129
131
)
130
- )
132
+ }
131
133
}
132
134
133
135
if (
You can’t perform that action at this time.
0 commit comments