@@ -31,9 +31,6 @@ final class AugmentedForm implements Form {
3131
3232 final Map <String , Object >? _userProvidedUriVariables;
3333
34- /// The identifier of the [_thingDescription] associated with this form.
35- String get tdIdentifier => _thingDescription.identifier;
36-
3734 @override
3835 Map <String , dynamic > get additionalFields => _form.additionalFields;
3936
@@ -47,8 +44,9 @@ final class AugmentedForm implements Form {
4744 @override
4845 String get contentType => _form.contentType;
4946
50- @override
51- Uri get href {
47+ /// Resolves all [_userProvidedUriVariables] in this [Form] and returns the
48+ /// resulting [Uri] .
49+ Uri get _resolvedHref {
5250 final baseUri = _thingDescription.base ;
5351
5452 if (baseUri != null ) {
@@ -58,6 +56,39 @@ final class AugmentedForm implements Form {
5856 return _form.href;
5957 }
6058
59+ @override
60+ Uri get href {
61+ final href = _resolvedHref;
62+ final hrefUriVariables = _filterUriVariables (href);
63+
64+ if (hrefUriVariables.isEmpty) {
65+ return href;
66+ }
67+
68+ final Map <String , DataSchema > affordanceUriVariables = {
69+ ..._thingDescription.uriVariables ?? {},
70+ ..._interactionAffordance.uriVariables ?? {},
71+ };
72+
73+ final userProvidedUriVariables = _userProvidedUriVariables;
74+
75+ if (userProvidedUriVariables != null ) {
76+ _validateUriVariables (
77+ hrefUriVariables,
78+ affordanceUriVariables,
79+ userProvidedUriVariables,
80+ );
81+ }
82+
83+ // As "{" and "}" are "percent encoded" due to Uri.parse(), we need to
84+ // revert the encoding first before we can insert the values.
85+ final decodedHref = Uri .decodeFull (href.toString ());
86+
87+ final expandedHref =
88+ UriTemplate (decodedHref).expand (userProvidedUriVariables ?? {});
89+ return Uri .parse (expandedHref);
90+ }
91+
6192 @override
6293 List <OperationType > get op =>
6394 _form.op ?? OperationType .defaultOpValues (_interactionAffordance);
@@ -98,38 +129,6 @@ final class AugmentedForm implements Form {
98129 .toList (growable: false );
99130 }
100131
101- /// Resolves all [_userProvidedUriVariables] in this [Form] and returns the
102- /// resulting [Uri] .
103- Uri get resolvedHref {
104- final hrefUriVariables = _filterUriVariables (href);
105-
106- if (hrefUriVariables.isEmpty) {
107- return href;
108- }
109-
110- final Map <String , DataSchema > affordanceUriVariables = {
111- ..._thingDescription.uriVariables ?? {},
112- ..._interactionAffordance.uriVariables ?? {},
113- };
114-
115- final userProvidedUriVariables = _userProvidedUriVariables;
116- if (userProvidedUriVariables != null ) {
117- _validateUriVariables (
118- hrefUriVariables,
119- affordanceUriVariables,
120- userProvidedUriVariables,
121- );
122- }
123-
124- // As "{" and "}" are "percent encoded" due to Uri.parse(), we need to
125- // revert the encoding first before we can insert the values.
126- final decodedHref = Uri .decodeFull (href.toString ());
127-
128- final expandedHref =
129- UriTemplate (decodedHref).expand (userProvidedUriVariables ?? {});
130- return Uri .parse (expandedHref);
131- }
132-
133132 void _validateUriVariables (
134133 List <String > uriVariablesInHref,
135134 Map <String , DataSchema > affordanceUriVariables,
0 commit comments