Skip to content

Commit 2a93ac9

Browse files
easyas314159silvanocerza
authored andcommitted
Fix lib install --git-url removing last char from lib name (#1462)
TrimRight greedily removes as any matching characters from the cutset as possible which can inadvertently remove characters from the library name.
1 parent 4bbacd3 commit 2a93ac9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: arduino/libraries/librariesmanager/install.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ func parseGitURL(gitURL string) (string, error) {
240240
if strings.HasPrefix(gitURL, "git@") {
241241
// We can't parse these as URLs
242242
i := strings.LastIndex(gitURL, "/")
243-
res = strings.TrimRight(gitURL[i+1:], ".git")
243+
res = strings.TrimSuffix(gitURL[i+1:], ".git")
244244
} else if path := paths.New(gitURL); path.Exist() {
245245
res = path.Base()
246246
} else if parsed, err := url.Parse(gitURL); err == nil {
247247
i := strings.LastIndex(parsed.Path, "/")
248-
res = strings.TrimRight(parsed.Path[i+1:], ".git")
248+
res = strings.TrimSuffix(parsed.Path[i+1:], ".git")
249249
} else {
250250
return "", fmt.Errorf(tr("invalid git url"))
251251
}

0 commit comments

Comments
 (0)