Skip to content

Commit

Permalink
#119 trailing slash fix and release version update (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm authored Jan 26, 2018
1 parent b8d3265 commit 00cb083
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Resty [![Build Status](https://travis-ci.org/go-resty/resty.svg?branch=master)](https://travis-ci.org/go-resty/resty) [![codecov](https://codecov.io/gh/go-resty/resty/branch/master/graph/badge.svg)](https://codecov.io/gh/go-resty/resty/branch/master) [![GoReport](https://goreportcard.com/badge/go-resty/resty)](https://goreportcard.com/report/go-resty/resty) [![Version](https://img.shields.io/badge/version-1.1-blue.svg)](https://github.com/go-resty/resty/releases/latest) [![GoDoc](https://godoc.org/github.com/go-resty/resty?status.svg)](https://godoc.org/github.com/go-resty/resty) [![License](https://img.shields.io/github/license/go-resty/resty.svg)](LICENSE)
# Resty [![Build Status](https://travis-ci.org/go-resty/resty.svg?branch=master)](https://travis-ci.org/go-resty/resty) [![codecov](https://codecov.io/gh/go-resty/resty/branch/master/graph/badge.svg)](https://codecov.io/gh/go-resty/resty/branch/master) [![GoReport](https://goreportcard.com/badge/go-resty/resty)](https://goreportcard.com/report/go-resty/resty) [![Version](https://img.shields.io/badge/version-1.2-blue.svg)](https://github.com/go-resty/resty/releases/latest) [![GoDoc](https://godoc.org/github.com/go-resty/resty?status.svg)](https://godoc.org/github.com/go-resty/resty) [![License](https://img.shields.io/github/license/go-resty/resty.svg)](LICENSE)

Simple HTTP and REST client for Go inspired by Ruby rest-client. [Features](#features) section describes in detail about Resty capabilities.

***v1.1 [released](https://github.com/go-resty/resty/releases/latest) and tagged on Jan 25, 2018.***
***v1.2 [released](https://github.com/go-resty/resty/releases/latest) and tagged on Jan 26, 2018.***

*Since Go v1.6 HTTP/2 & HTTP/1.1 protocol is used transparently. `Resty` works fine with HTTP/2 and HTTP/1.1.*

Expand Down
2 changes: 1 addition & 1 deletion resty.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
package resty

// Version # of resty
const Version = "1.2-edge"
const Version = "1.2"
9 changes: 9 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ func composeRequestURL(pathURL string, c *Client, r *Request) string {
pathURL = "/" + pathURL
}

hasTrailingSlash := false
if strings.HasSuffix(pathURL, "/") && len(pathURL) > 1 {
hasTrailingSlash = true
}

reqURL := "/"
for _, segment := range strings.Split(pathURL, "/") {
if strings.HasPrefix(segment, "{") && strings.HasSuffix(segment, "}") {
Expand All @@ -229,5 +234,9 @@ func composeRequestURL(pathURL string, c *Client, r *Request) string {
reqURL = path.Join(reqURL, segment)
}

if hasTrailingSlash {
reqURL = reqURL + "/"
}

return reqURL
}

0 comments on commit 00cb083

Please sign in to comment.