File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { PACKAGE_NAMES } from '../constants'
2
2
import '../releases/__mocks__/index'
3
3
import {
4
4
getVersionsContentInDiff ,
5
+ removeAppPathPrefix ,
5
6
replaceAppDetails ,
6
7
getChangelogURL ,
7
8
} from '../utils'
@@ -132,3 +133,21 @@ describe('replaceAppDetails ', () => {
132
133
}
133
134
)
134
135
} )
136
+
137
+ describe ( 'removeAppPathPrefix' , ( ) => {
138
+ test . each ( [
139
+ [ 'RnDiffApp/package.json' , 'package.json' ] ,
140
+ [ 'RnDiffApp/RnDiffApp.ts' , 'RnDiffApp.ts' ] ,
141
+ ] ) ( 'removeAppPathPrefix("%s") -> "%s"' , ( path , newPath ) => {
142
+ expect ( removeAppPathPrefix ( path ) ) . toEqual ( newPath )
143
+ } )
144
+
145
+ test ( 'removeAppPathPrefix custom AppName' , ( ) => {
146
+ expect ( removeAppPathPrefix ( 'RnDiffApp/package.json' , '' ) ) . toEqual (
147
+ 'RnDiffApp/package.json'
148
+ )
149
+ expect ( removeAppPathPrefix ( 'Foobar/package.json' , 'Foobar' ) ) . toEqual (
150
+ 'package.json'
151
+ )
152
+ } )
153
+ } )
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export const getBinaryFileURL = ({
75
75
}
76
76
77
77
export const removeAppPathPrefix = ( path : string , appName = DEFAULT_APP_NAME ) =>
78
- path . replace ( new RegExp ( `${ appName } /` ) , '' )
78
+ path . replace ( new RegExp ( `^ ${ appName } /` ) , '' )
79
79
80
80
/**
81
81
* Replaces DEFAULT_APP_PACKAGE and DEFAULT_APP_NAME in str with custom
You can’t perform that action at this time.
0 commit comments