From 7fb510f366fec0ebe88f847b2abe0b88fe150505 Mon Sep 17 00:00:00 2001 From: Roland Gritzer Date: Wed, 22 Jan 2020 16:49:31 +0100 Subject: [PATCH] fixed hasTrailingSlash, formating --- restapi/resource_api_object.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/restapi/resource_api_object.go b/restapi/resource_api_object.go index 88c0c5cf..cf6f1a1e 100644 --- a/restapi/resource_api_object.go +++ b/restapi/resource_api_object.go @@ -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, "/") } @@ -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))