@@ -44,8 +44,9 @@ final class AugmentedForm implements Form {
4444 @override
4545 String get contentType => _form.contentType;
4646
47- @override
48- Uri get href {
47+ /// Resolves all [_userProvidedUriVariables] in this [Form] and returns the
48+ /// resulting [Uri] .
49+ Uri get _resolvedHref {
4950 final baseUri = _thingDescription.base ;
5051
5152 if (baseUri != null ) {
@@ -55,6 +56,39 @@ final class AugmentedForm implements Form {
5556 return _form.href;
5657 }
5758
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+
5892 @override
5993 List <OperationType > get op =>
6094 _form.op ?? OperationType .defaultOpValues (_interactionAffordance);
@@ -95,38 +129,6 @@ final class AugmentedForm implements Form {
95129 .toList (growable: false );
96130 }
97131
98- /// Resolves all [_userProvidedUriVariables] in this [Form] and returns the
99- /// resulting [Uri] .
100- Uri get resolvedHref {
101- final hrefUriVariables = _filterUriVariables (href);
102-
103- if (hrefUriVariables.isEmpty) {
104- return href;
105- }
106-
107- final Map <String , DataSchema > affordanceUriVariables = {
108- ..._thingDescription.uriVariables ?? {},
109- ..._interactionAffordance.uriVariables ?? {},
110- };
111-
112- final userProvidedUriVariables = _userProvidedUriVariables;
113- if (userProvidedUriVariables != null ) {
114- _validateUriVariables (
115- hrefUriVariables,
116- affordanceUriVariables,
117- userProvidedUriVariables,
118- );
119- }
120-
121- // As "{" and "}" are "percent encoded" due to Uri.parse(), we need to
122- // revert the encoding first before we can insert the values.
123- final decodedHref = Uri .decodeFull (href.toString ());
124-
125- final expandedHref =
126- UriTemplate (decodedHref).expand (userProvidedUriVariables ?? {});
127- return Uri .parse (expandedHref);
128- }
129-
130132 void _validateUriVariables (
131133 List <String > uriVariablesInHref,
132134 Map <String , DataSchema > affordanceUriVariables,
0 commit comments