Skip to content

Commit a982edc

Browse files
Copilotmmsmits
andcommitted
Refactor InMemoryResourceResolver to use Canonical class for URI parsing
Co-authored-by: mmsmits <8956842+mmsmits@users.noreply.github.com>
1 parent ed67b8d commit a982edc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Hl7.Fhir.Base/Specification/Source/InMemoryResourceResolver.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@ private void add(Resource resource)
9898
///<inheritdoc/>
9999
public Resource? ResolveByCanonicalUri(string uri)
100100
{
101-
var values = uri.Split('|');
102-
if (values.Length > 2)
103-
throw new ArgumentException("Url is not valid. The pipe occurs more than once.");
104-
105-
var canonicalUrl = values[0];
106-
var version = values.Length == 2 ? values[1] : string.Empty;
101+
var canonical = new Canonical(uri);
102+
var canonicalUrl = canonical.Uri;
103+
var version = canonical.Version ?? string.Empty;
107104

108105
// Filter by canonical URL first
109106
var candidateResources = _resources.Where(r => r.Url == canonicalUrl).ToList();

0 commit comments

Comments
 (0)