@@ -44,8 +44,9 @@ final class AugmentedForm implements Form {
44
44
@override
45
45
String get contentType => _form.contentType;
46
46
47
- @override
48
- Uri get href {
47
+ /// Resolves all [_userProvidedUriVariables] in this [Form] and returns the
48
+ /// resulting [Uri] .
49
+ Uri get _resolvedHref {
49
50
final baseUri = _thingDescription.base ;
50
51
51
52
if (baseUri != null ) {
@@ -55,6 +56,39 @@ final class AugmentedForm implements Form {
55
56
return _form.href;
56
57
}
57
58
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
+
58
92
@override
59
93
List <OperationType > get op =>
60
94
_form.op ?? OperationType .defaultOpValues (_interactionAffordance);
@@ -95,38 +129,6 @@ final class AugmentedForm implements Form {
95
129
.toList (growable: false );
96
130
}
97
131
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
-
130
132
void _validateUriVariables (
131
133
List <String > uriVariablesInHref,
132
134
Map <String , DataSchema > affordanceUriVariables,
0 commit comments