MCPcopy Create free account
hub / github.com/EvilFreelancer/openapi-to-cli / splitRef

Method splitRef

src/openapi-loader.ts:169–184  ·  view source on GitHub ↗
(ref: string, currentSource: string)

Source from the content-addressed store, hash-verified

167 }
168
169 private splitRef(ref: string, currentSource: string): { source: string; pointer: string } {
170 const [refSource, pointer = ""] = ref.split("#", 2);
171 if (!refSource) {
172 return { source: currentSource, pointer };
173 }
174
175 if (refSource.startsWith("http://") || refSource.startsWith("https://")) {
176 return { source: refSource, pointer };
177 }
178
179 if (currentSource.startsWith("http://") || currentSource.startsWith("https://")) {
180 return { source: new URL(refSource, currentSource).toString(), pointer };
181 }
182
183 return { source: path.resolve(path.dirname(currentSource), refSource), pointer };
184 }
185
186 private resolvePointer(document: unknown, pointer: string): unknown {
187 if (!pointer) {

Callers 1

resolveRefMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected