Skip to content

Commit e827598

Browse files
committed
Clean up logic for determining whether a locator or identifier references an external resource
1 parent 43351ca commit e827598

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ private static (string, string) GetReferenceIdAndExternalResource(string pointer
157157
string refId = !pointer.Contains('#') ? pointer : refSegments.Last();
158158

159159
var isExternalResource = !refSegments.First().StartsWith("#");
160-
string externalResource = isExternalResource
161-
? $"{refSegments.First()}/{refSegments[1].TrimEnd('#')}"
162-
: null;
160+
string externalResource = null;
161+
if (isExternalResource && pointer.Contains('#'))
162+
{
163+
externalResource = $"{refSegments.First()}/{refSegments[1].TrimEnd('#')}";
164+
}
163165

164166
return (refId, externalResource);
165167
}

0 commit comments

Comments
 (0)