Skip to content

Commit 1db5944

Browse files
authored
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 88a3900 commit 1db5944

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
@@ -245,12 +245,12 @@ func parseGitURL(gitURL string) (string, error) {
245245
if strings.HasPrefix(gitURL, "git@") {
246246
// We can't parse these as URLs
247247
i := strings.LastIndex(gitURL, "/")
248-
res = strings.TrimRight(gitURL[i+1:], ".git")
248+
res = strings.TrimSuffix(gitURL[i+1:], ".git")
249249
} else if path := paths.New(gitURL); path.Exist() {
250250
res = path.Base()
251251
} else if parsed, err := url.Parse(gitURL); err == nil {
252252
i := strings.LastIndex(parsed.Path, "/")
253-
res = strings.TrimRight(parsed.Path[i+1:], ".git")
253+
res = strings.TrimSuffix(parsed.Path[i+1:], ".git")
254254
} else {
255255
return "", fmt.Errorf(tr("invalid git url"))
256256
}

0 commit comments

Comments
 (0)