Skip to content

Commit 36004ef

Browse files
committed
Improve version number regex in installation script
The installation script scrapes the GitHub releases page for the version number of the latest release. A regular expression is used to extract the version number from the title. Previously, the regular expression would return a corrupted version number if the name of the repository owner or repository contained numbers. For example, if used in a repository owned by GitHub user `per1234`, where the latest release version was 1.2.3, it would return the following version number: ``` 1.2.3 1234 ```
1 parent d56cc81 commit 36004ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

etc/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ initDownloadTool() {
8484
checkLatestVersion() {
8585
# Use the GitHub releases webpage to find the latest version for this project
8686
# so we don't get rate-limited.
87-
CHECKLATESTVERSION_REGEX="[0-9][A-Za-z0-9\.-]*"
87+
CHECKLATESTVERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\.-]+)?"
8888
CHECKLATESTVERSION_LATEST_URL="https://github.com/${PROJECT_OWNER}/${PROJECT_NAME}/releases/latest"
8989
if [ "$DOWNLOAD_TOOL" = "curl" ]; then
9090
CHECKLATESTVERSION_TAG=$(curl -SsL $CHECKLATESTVERSION_LATEST_URL | grep --extended-regexp -o "<title>Release $CHECKLATESTVERSION_REGEX · ${PROJECT_OWNER}/${PROJECT_NAME}" | grep --extended-regexp -o "$CHECKLATESTVERSION_REGEX")

0 commit comments

Comments
 (0)