aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/url.go
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/url.go')
-rw-r--r--accounts/url.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/accounts/url.go b/accounts/url.go
index 47f9d8ee4..21df668ef 100644
--- a/accounts/url.go
+++ b/accounts/url.go
@@ -74,6 +74,22 @@ func (u URL) MarshalJSON() ([]byte, error) {
return json.Marshal(u.String())
}
+// UnmarshalJSON parses url.
+func (u *URL) UnmarshalJSON(input []byte) error {
+ var textUrl string
+ err := json.Unmarshal(input, &textUrl)
+ if err != nil {
+ return err
+ }
+ url, err := parseURL(textUrl)
+ if err != nil {
+ return err
+ }
+ u.Scheme = url.Scheme
+ u.Path = url.Path
+ return nil
+}
+
// Cmp compares x and y and returns:
//
// -1 if x < y