package octokit

import (
	"github.com/jtacoma/uritemplates"
	"net/url"
)

// TODO: use sawyer.Hyperlink

type M map[string]interface{}

type Hyperlink string

func (l *Hyperlink) Expand(m M) (u *url.URL, err error) {
	template, e := uritemplates.Parse(string(*l))
	if e != nil {
		err = e
		return
	}

	expanded, e := template.Expand(m)
	if e != nil {
		err = e
		return
	}

	u, err = url.Parse(expanded)
	return
}

package octokit

import (
	"github.com/lostisland/go-sawyer"
	"net/url"
)

type M map[string]interface{}

type Hyperlink string

// TODO: find out a way to not wrapping sawyer.Hyperlink like this
func (l *Hyperlink) Expand(m M) (u *url.URL, err error) {
	link := sawyer.Hyperlink(string(*l))
	sawyerM := sawyer.M{}
	for k, v := range m {
		sawyerM[k] = v
	}

	u, err = link.Expand(sawyerM)
	return
}

--- 
+++ 
@@ -1,22 +1,29 @@
 package octokit
 
 import (
-	"github.com/lostisland/go-sawyer"
+	"github.com/jtacoma/uritemplates"
 	"net/url"
 )
+
+// TODO: use sawyer.Hyperlink
 
 type M map[string]interface{}
 
 type Hyperlink string
 
-// TODO: find out a way to not wrapping sawyer.Hyperlink like this
 func (l *Hyperlink) Expand(m M) (u *url.URL, err error) {
-	link := sawyer.Hyperlink(string(*l))
-	sawyerM := sawyer.M{}
-	for k, v := range m {
-		sawyerM[k] = v
+	template, e := uritemplates.Parse(string(*l))
+	if e != nil {
+		err = e
+		return
 	}
 
-	u, err = link.Expand(sawyerM)
+	expanded, e := template.Expand(m)
+	if e != nil {
+		err = e
+		return
+	}
+
+	u, err = url.Parse(expanded)
 	return
 }
Revert "Use sawyer.Hyperlink and sawyer.M"

This reverts commit 52f030c42273e3a38543e1148d047523bd7fff0a.
