Files
playlet-piped/playlet-lib/src/components/Services/ApplicationInfo/LatestLibVersionTask.bs
T
Brahim Hadriche 7e5b2246fa [refactor] web server routing system (#270)
* [refactor] web server routing system

* regex literal

* Docs
2024-01-15 19:25:13 -05:00

26 lines
716 B
Plaintext

import "pkg:/source/services/HttpClient.bs"
@asynctask
function LatestLibVersionTask() as object
latest = GetLatestPlayletLibVersionFromGithubReleases()
return {
latest: latest
}
end function
function GetLatestPlayletLibVersionFromGithubReleases() as string
response = HttpClient.Head("https://github.com/iBicha/playlet/releases/latest").Await()
if response.StatusCode() = 200
headers = response.Headers()
if headers.location <> invalid
regex = /\/v?(\d+\.\d+\.\d+)/
match = regex.match(headers.location)
if match.Count() = 2
return match[1]
end if
end if
end if
return "N/A"
end function