Skip to content

Commit

Permalink
Support python libraries with + in the file name (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
levpachmanov authored Apr 5, 2024
1 parent 0093dee commit bb669f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion utils/pythonutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pythonutils
import (
"errors"
"fmt"
"net/url"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -307,5 +308,12 @@ func extractFileNameFromRegexCaptureGroup(pattern *gofrogcmd.CmdOutputPattern) (
if lastSlashIndex == -1 {
return filePath
}
return filePath[lastSlashIndex+1:]
lastComponent := filePath[lastSlashIndex+1:]
// Unescape the last component, for example 'PyYAML-5.1.2%2Bsp1.tar.gz' -> 'PyYAML-5.1.2+sp1.tar.gz'.
unescapedComponent, _ := url.QueryUnescape(lastComponent)
if unescapedComponent == "" {
// Couldn't escape, will use the raw string
return lastComponent
}
return unescapedComponent
}
14 changes: 14 additions & 0 deletions utils/pythonutils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ Collecting PyYAML==5.1.2 (from jfrog-python-example==1.0)
Installing build dependencies: started`,
expectedCapture: `PyYAML-5.1.2.tar.gz`,
},
{
name: "Downloading - multi line captures",
startCapturePattern: startDownloadingPattern,
captureGroupPattern: downloadingCaptureGroup,
endCapturePattern: endPattern,
text: ` Preparing metadata (pyproject.toml): finished with status 'done'
Collecting PyYAML==5.1.2 (from jfrog-python-example==1.0)
Downloading http://localhost:8081/artifactory/api/pypi/cli-pypi-virtual-1698
829558/packages/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849
582fe/PyYAML-5.1.2%2Bsp1.tar.gz (265 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 265.0/265.0 kB 364.4 MB/s eta 0:00:00
Installing build dependencies: started`,
expectedCapture: `PyYAML-5.1.2+sp1.tar.gz`,
},
}

for _, testCase := range tests {
Expand Down

0 comments on commit bb669f3

Please sign in to comment.