Skip to content

Commit

Permalink
refs #114. parse query string in the path not starting with slash.
Browse files Browse the repository at this point in the history
  • Loading branch information
huandu committed Sep 6, 2018
1 parent c127ce6 commit 2614040
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Change Log #

## v2.3.2 ##

* `[FIX]` [#114](https://github.com/huandu/facebook/pull/114) Correctly parse query string in the path which doesn't start with '/', e.g. `fb.Get("me?fields=name,email", nil)`.

## v2.3.1 ##

* `[FIX]` [#114](https://github.com/huandu/facebook/pull/114) Query string in the path (e.g. `fb.Get("/me?fields=name,email", nil)`) works as expected now. Thanks, [@AsifArko](https://github.com/AsifArko).
* `[FIX]` [#114](https://github.com/huandu/facebook/pull/114) Query string in the path, e.g. `fb.Get("/me?fields=name,email", nil)`, works as expected now. Thanks, [@AsifArko](https://github.com/AsifArko).

## v2.3.0 ##

Expand Down
2 changes: 1 addition & 1 deletion facebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
FB_TEST_APP_SECRET = "b2e4262c306caa3c7f5215d2d099b319"

// remeber to change it to a valid token to run test
FB_TEST_VALID_ACCESS_TOKEN = ""
FB_TEST_VALID_ACCESS_TOKEN = "EAACZA38ZAD8CoBAPZALNFWJ3ZA5IYHNYwEDqaXr1o148xisnghXZBw3Df1mSXV1xWjOShk87FWZAfgSZCtOyZC0mHYH18W6oKAfzSFohMcZACYm90PQDKZA26XZAzBTJZBORoo2o97uU4QGuZC45X9EwtMM3scoi6ojv5AdFsHe2HB8aWVX7BFWB8aIAKq1bo7df3AFMZD"

// remember to change it to a valid signed request to run test
//FB_TEST_VALID_SIGNED_REQUEST = "ZAxP-ILRQBOwKKxCBMNlGmVraiowV7WFNg761OYBNGc.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEzNDM0OTg0MDAsImlzc3VlZF9hdCI6MTM0MzQ5MzI2NSwib2F1dGhfdG9rZW4iOiJBQUFDWkEzOFpBRDhDb0JBRFpCcmZ5TFpDanBNUVczdThVTWZmRldSWkNpZGw5Tkx4a1BsY2tTcXZaQnpzTW9OWkF2bVk2RUd2NG1hUUFaQ0t2VlpBWkJ5VXA5a0FCU2x6THFJejlvZTdOdHBzdzhyQVpEWkQiLCJ1c2VyIjp7ImNvdW50cnkiOiJ1cyIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fSwidXNlcl9pZCI6IjUzODc0NDQ2OCJ9"
Expand Down
5 changes: 5 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ func (session *Session) graph(path string, method Method, params Params) (res Re
// parse path only if path contains '?'.
// url.ParseRequestURI cannot parse uri without "/" like "me".
if strings.Contains(path, "?") {
// make sure the path starts with a slash.
if path[0] != '/' {
path = "/" + path
}

// parse query string in path.
u, e := url.ParseRequestURI(path)

Expand Down
2 changes: 1 addition & 1 deletion session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func TestGetWithQueryString(t *testing.T) {

t.Logf("current user id is %v", id)

result, e := Api("/me?access_token="+FB_TEST_VALID_ACCESS_TOKEN, GET, Params{
result, e := Api("me?access_token="+FB_TEST_VALID_ACCESS_TOKEN, GET, Params{
"fields": "name,email",
})

Expand Down

0 comments on commit 2614040

Please sign in to comment.