@@ -242,7 +242,7 @@ export function fsPathFromUrl(url: string): string {
242
242
* @returns true if dir is a parent of file
243
243
*/
244
244
export function isParentDirectory ( dir : string , file : string ) : boolean {
245
- if ( ! dir . endsWith ( '/' ) ) {
245
+ if ( dir [ dir . length - 1 ] !== '/' ) {
246
246
dir = `${ dir } /`
247
247
}
248
248
return (
@@ -276,7 +276,7 @@ export const isJSRequest = (url: string): boolean => {
276
276
if ( knownJsSrcRE . test ( url ) ) {
277
277
return true
278
278
}
279
- if ( ! path . extname ( url ) && ! url . endsWith ( '/' ) ) {
279
+ if ( ! path . extname ( url ) && url [ url . length - 1 ] !== '/' ) {
280
280
return true
281
281
}
282
282
return false
@@ -292,7 +292,7 @@ const splitFilePathAndQueryRE = /(\.(?:[cm]?js|jsx))(\?.*)?$/
292
292
export function getPotentialTsSrcPaths ( filePath : string ) : string [ ] {
293
293
const [ name , type , query = '' ] = filePath . split ( splitFilePathAndQueryRE )
294
294
const paths = [ name + type . replace ( 'js' , 'ts' ) + query ]
295
- if ( ! type . endsWith ( 'x' ) ) {
295
+ if ( type [ type . length - 1 ] !== 'x' ) {
296
296
paths . push ( name + type . replace ( 'js' , 'tsx' ) + query )
297
297
}
298
298
return paths
@@ -1146,8 +1146,8 @@ function normalizeSingleAlias({
1146
1146
} : Alias ) : Alias {
1147
1147
if (
1148
1148
typeof find === 'string' &&
1149
- find . endsWith ( '/' ) &&
1150
- replacement . endsWith ( '/' )
1149
+ find [ find . length - 1 ] === '/' &&
1150
+ replacement [ replacement . length - 1 ] === '/'
1151
1151
) {
1152
1152
find = find . slice ( 0 , find . length - 1 )
1153
1153
replacement = replacement . slice ( 0 , replacement . length - 1 )
@@ -1239,7 +1239,7 @@ export function joinUrlSegments(a: string, b: string): string {
1239
1239
if ( ! a || ! b ) {
1240
1240
return a || b || ''
1241
1241
}
1242
- if ( a . endsWith ( '/' ) ) {
1242
+ if ( a [ a . length - 1 ] === '/' ) {
1243
1243
a = a . substring ( 0 , a . length - 1 )
1244
1244
}
1245
1245
if ( b [ 0 ] !== '/' ) {
@@ -1256,7 +1256,7 @@ export function stripBase(path: string, base: string): string {
1256
1256
if ( path === base ) {
1257
1257
return '/'
1258
1258
}
1259
- const devBase = base . endsWith ( '/' ) ? base : base + '/'
1259
+ const devBase = base [ base . length - 1 ] === '/' ? base : base + '/'
1260
1260
return path . startsWith ( devBase ) ? path . slice ( devBase . length - 1 ) : path
1261
1261
}
1262
1262
0 commit comments