@@ -136,22 +136,28 @@ export const generate = <T>(entryPoint: string, currentPoint: string, reference:
136
136
throw new NotFoundFileError ( `Not found reference point from current point. \n Path: ${ referencePoint } ` ) ;
137
137
}
138
138
139
- const relativePathFromEntryPoint = path . relative ( path . dirname ( entryPoint ) , referencePoint ) ; // components/hoge/fuga.yml
140
- const ext = path . extname ( relativePathFromEntryPoint ) ; // .yml
141
- const pathArray : string [ ] = relativePathFromEntryPoint . replace ( ext , "" ) . split ( path . sep ) ; // ["components", "hoge", "fuga"]
142
- const targetPath : string = pathArray . join ( "/" ) ; // components/hoge/fuga
139
+ const fragmentIndex = referencePoint . indexOf ( "#/" ) ;
140
+ let targetPath : string ;
141
+ if ( fragmentIndex !== - 1 ) {
142
+ targetPath = referencePoint . substring ( fragmentIndex + 2 ) ;
143
+ } else {
144
+ const relativePathFromEntryPoint = path . relative ( path . dirname ( entryPoint ) , referencePoint ) ; // components/hoge/fuga.yml
145
+ if ( ! relativePathFromEntryPoint . startsWith ( "components" ) ) {
146
+ throw new DevelopmentError ( `targetPath is not start "components":\n${ relativePathFromEntryPoint } ` ) ;
147
+ }
148
+
149
+ const ext = path . extname ( relativePathFromEntryPoint ) ; // .yml
150
+ targetPath = relativePathFromEntryPoint . substring ( 0 , relativePathFromEntryPoint . length - ext . length ) ; // components/hoge/fuga
151
+ }
152
+ const pathArray : string [ ] = targetPath . split ( path . sep ) ; // ["components", "hoge", "fuga"]
143
153
const schemaName = pathArray [ pathArray . length - 1 ] ; // fuga
144
154
const componentName = pathArray [ 0 ] === "components" ? pathArray [ 1 ] : "" ;
145
- const data = FileSystem . loadJsonOrYaml ( referencePoint ) ;
146
155
156
+ const data = FileSystem . loadJsonOrYaml ( referencePoint ) ;
147
157
if ( Guard . isReference ( data ) ) {
148
158
return generate < T > ( entryPoint , referencePoint , data ) ;
149
159
}
150
160
151
- if ( ! targetPath . startsWith ( "components" ) ) {
152
- throw new DevelopmentError ( `targetPath is not start "components":\n${ targetPath } ` ) ;
153
- }
154
-
155
161
return {
156
162
type : "remote" ,
157
163
referencePoint,
0 commit comments