Skip to content

Commit

Permalink
Merge branch 'bugfix/trailing-slash'
Browse files Browse the repository at this point in the history
  • Loading branch information
landorg committed Jan 22, 2020
2 parents ac2da1f + 7fb510f commit 1550a32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions restapi/resource_api_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ func resourceRestApi() *schema.Resource {
func resourceRestApiImport(d *schema.ResourceData, meta interface{}) (imported []*schema.ResourceData, err error) {
input := d.Id()

hasTrailingSlash := strings.LastIndex(input, "/") == len(input)
hasTrailingSlash := strings.LastIndex(input, "/") == len(input)-1
var n int
if (hasTrailingSlash) {
n = strings.LastIndex(input[0:len(input)-1], "/")
n = strings.LastIndex(input[0 : len(input) - 1], "/")
} else {
n = strings.LastIndex(input, "/")
}
Expand All @@ -123,9 +123,9 @@ func resourceRestApiImport(d *schema.ResourceData, meta interface{}) (imported [

var id string
if (hasTrailingSlash) {
id = input[n+1 : len(input)-1]
id = input[n + 1 : len(input) - 1]
} else {
id = input[n+1 : len(input)]
id = input[n + 1 : len(input)]
}

d.Set("data", fmt.Sprintf(`{ "id": "%s" }`, id))
Expand Down

0 comments on commit 1550a32

Please sign in to comment.