@@ -7,18 +7,24 @@ export default class {
77 return {
88 fromExternal : ( fileUrl ) => {
99 let result = fileUrl . replace ( / % 5 C / gi, '\\' ) ; // 1.6.x 버전 대응
10- if ( result . startsWith ( './bower_components' ) ) { // 웹 기본 오브젝트 대응
10+ if ( result . startsWith ( './bower_components' ) ) {
11+ // 웹 기본 오브젝트 대응
1112 result = result
1213 . replace ( './bower_components' , '../../../node_modules' )
1314 . replace ( 'entryjs' , 'entry-js' ) ; // 과거 웹 WS 대응
14- } else if ( result . startsWith ( '/lib' ) ) { // 신규 웹 기본 오브젝트 대응
15+ } else if ( result . startsWith ( '/lib' ) ) {
16+ // 신규 웹 기본 오브젝트 대응
1517 result = result . replace ( '/lib' , '../../../node_modules' ) ;
16- } else if ( result . indexOf ( 'temp' ) > - 1 ) { // 일반 오브젝트 대응
18+ } else if ( result . indexOf ( 'temp' ) > - 1 ) {
19+ // 일반 오브젝트 대응
1720 result = result . substring ( result . indexOf ( 'temp' ) ) ;
18- result = path . join ( this . appPath , result )
19- . replace ( / \\ / gi, '/' ) ;
21+ result = path . join ( this . appPath , result ) . replace ( / \\ / gi, '/' ) ;
22+ } else if ( result . match ( '/node_modules/@entrylabs/entry' ) !== null ) {
23+ result = result . replace (
24+ '/node_modules/@entrylabs/entry' ,
25+ '../../../node_modules/entry-js'
26+ ) ;
2027 }
21-
2228 // TODO: 히스토리 파악 후 완전 제거
2329 // if (fileUrl.endsWith('.svg')) {
2430 // // svg 파일의 경우 png 파일로 교체한다.
@@ -33,15 +39,16 @@ export default class {
3339
3440 if ( result . startsWith ( 'renderer' ) ) {
3541 result = result . replace ( 'renderer' , '.' ) ;
42+ } else if ( result . startsWith ( '../../../node_modules' ) ) {
43+ // 웹 업로드시 bower 에서 받던 구조 그대로 사용할 것이므로, 그 사이에 혼동을 주지 않기 위해
44+ // node_modules 로 링크되는 구조를 과거 로직으로 재치환 하여 export 함
45+ result = result . replace ( '../../../node_modules' , './bower_components' ) ;
46+ } else if ( result . match ( '/node_modules/@entrylabs/entry' ) !== null ) {
47+ result = result . replace ( '/node_modules/@entrylabs/entry' , './bower_components' ) ;
3648 }
3749
38- // 웹 업로드시 bower 에서 받던 구조 그대로 사용할 것이므로, 그 사이에 혼동을 주지 않기 위해
39- // node_modules 로 링크되는 구조를 과거 로직으로 재치환 하여 export 함
40- if ( result . startsWith ( '../../../node_modules' ) ) {
41- result = result . replace ( '../../../node_modules' , './bower_components' ) ;
42- }
43-
44- return result . substring ( result . indexOf ( 'temp' ) )
50+ return result
51+ . substring ( result . indexOf ( 'temp' ) )
4552 . replace ( / \\ / gi, '/' )
4653 . replace ( / .* \/ \/ / , '' ) ; // 외부 접속 프로토콜 스키마 보안 대응
4754 } ,
@@ -51,7 +58,7 @@ export default class {
5158 if ( result . startsWith ( 'renderer' ) ) {
5259 result = result . replace ( 'renderer' , '.' ) ;
5360 } else if ( result . startsWith ( '../../../node_modules' ) ) {
54- result = result . replace ( '../../../node_modules' , './bower_components' ) ;
61+ result = result . replace ( '../../../node_modules' , './bower_components' ) ;
5562 } else {
5663 result = undefined ;
5764 }
@@ -105,87 +112,43 @@ export default class {
105112 }
106113
107114 static tempPathForExport ( objectId : string ) {
108- return path . join (
109- this . appPath ,
110- 'import' ,
111- objectId ,
112- path . sep ,
113- ) ;
115+ return path . join ( this . appPath , 'import' , objectId , path . sep ) ;
114116 }
115117
116118 // 사용위치는 join 을 사용 (프로젝트 외 경로)
117119 static get tempPath ( ) {
118- return path . join (
119- this . appPath ,
120- 'temp' ,
121- path . sep ,
122- ) ;
120+ return path . join ( this . appPath , 'temp' , path . sep ) ;
123121 }
124122
125123 static tempImagePath ( filename : string ) {
126- return path . join (
127- this . tempPath ,
128- this . subDirectoryPath ( filename ) ,
129- 'image' ,
130- path . sep ,
131- ) ;
124+ return path . join ( this . tempPath , this . subDirectoryPath ( filename ) , 'image' , path . sep ) ;
132125 }
133126
134127 static tempThumbnailPath ( filename : string ) {
135- return path . join (
136- this . tempPath ,
137- this . subDirectoryPath ( filename ) ,
138- 'thumb' ,
139- path . sep ,
140- ) ;
128+ return path . join ( this . tempPath , this . subDirectoryPath ( filename ) , 'thumb' , path . sep ) ;
141129 }
142130
143131 static tempSoundPath ( filename : string ) {
144- return path . join (
145- this . tempPath ,
146- this . subDirectoryPath ( filename ) ,
147- 'sound' ,
148- path . sep ,
149- ) ;
132+ return path . join ( this . tempPath , this . subDirectoryPath ( filename ) , 'sound' , path . sep ) ;
150133 }
151134
152135 static get resourcePath ( ) {
153- return path . resolve (
154- app . getAppPath ( ) , 'src' , 'renderer' , 'resources' , 'uploads' ,
155- ) ;
136+ return path . resolve ( app . getAppPath ( ) , 'src' , 'renderer' , 'resources' , 'uploads' ) ;
156137 }
157138
158139 static resourceImagePath ( filename : string ) {
159- return path . join (
160- this . resourcePath ,
161- this . subDirectoryPath ( filename ) ,
162- 'image' ,
163- path . sep ,
164- ) ;
140+ return path . join ( this . resourcePath , this . subDirectoryPath ( filename ) , 'image' , path . sep ) ;
165141 }
166142
167143 static resourceThumbnailPath ( filename : string ) {
168- return path . join (
169- this . resourcePath ,
170- this . subDirectoryPath ( filename ) ,
171- 'thumb' ,
172- path . sep ,
173- ) ;
144+ return path . join ( this . resourcePath , this . subDirectoryPath ( filename ) , 'thumb' , path . sep ) ;
174145 }
175146
176147 static resourceSoundPath ( filename : string ) {
177- return path . join (
178- this . resourcePath ,
179- this . subDirectoryPath ( filename ) ,
180- path . sep ,
181- ) ;
148+ return path . join ( this . resourcePath , this . subDirectoryPath ( filename ) , path . sep ) ;
182149 }
183150
184151 static subDirectoryPath ( filename : string ) {
185- return path . join (
186- filename . substr ( 0 , 2 ) ,
187- filename . substr ( 2 , 2 ) ,
188- path . sep ,
189- ) ;
152+ return path . join ( filename . substr ( 0 , 2 ) , filename . substr ( 2 , 2 ) , path . sep ) ;
190153 }
191154}
0 commit comments