File tree 3 files changed +16
-7
lines changed
3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default function interpolateName(
28
28
let resourcePath = loaderResourcePath
29
29
30
30
if ( parsed . ext ) {
31
- ext = parsed . ext . substr ( 1 )
31
+ ext = parsed . ext . slice ( 1 )
32
32
}
33
33
34
34
if ( parsed . dir ) {
@@ -41,7 +41,7 @@ export default function interpolateName(
41
41
. relative ( context , resourcePath + '_' )
42
42
. replace ( / \\ / g, '/' )
43
43
. replace ( / \. \. ( \/ ) ? / g, '_$1' )
44
- directory = directory . substr ( 0 , directory . length - 1 )
44
+ directory = directory . slice ( 0 , directory . length - 1 )
45
45
} else {
46
46
directory = resourcePath . replace ( / \\ / g, '/' ) . replace ( / \. \. ( \/ ) ? / g, '_$1' )
47
47
}
@@ -59,7 +59,7 @@ export default function interpolateName(
59
59
const hashIdx = query . indexOf ( '#' )
60
60
61
61
if ( hashIdx >= 0 ) {
62
- query = query . substr ( 0 , hashIdx )
62
+ query = query . slice ( 0 , hashIdx )
63
63
}
64
64
}
65
65
Original file line number Diff line number Diff line change @@ -154,12 +154,9 @@ const getOutputAndPublicPath: GetOutputAndPublicPath = (
154
154
if ( configPublicPath ) {
155
155
if ( typeof configPublicPath === 'function' ) {
156
156
publicPath = configPublicPath ( fileName )
157
- } else if ( configPublicPath . endsWith ( '/' ) ) {
158
- publicPath = configPublicPath + fileName
159
157
} else {
160
- publicPath = ` ${ configPublicPath } / ${ fileName } `
158
+ publicPath = path . posix . join ( configPublicPath , fileName )
161
159
}
162
-
163
160
publicPath = JSON . stringify ( publicPath )
164
161
}
165
162
Original file line number Diff line number Diff line change
1
+ import { getOutputAndPublicPath } from '../lib/utils'
2
+
3
+ describe ( 'Utils package' , ( ) => {
4
+ it ( 'should create both paths' , ( ) => {
5
+ const { outputPath, publicPath } = getOutputAndPublicPath ( 'file.png' , {
6
+ outputPath : '/dist/img/' ,
7
+ publicPath : '/img' ,
8
+ } )
9
+ expect ( outputPath ) . toBe ( '/dist/img/file.png' )
10
+ expect ( publicPath ) . toBe ( '"/img/file.png"' )
11
+ } )
12
+ } )
You can’t perform that action at this time.
0 commit comments