phar-io / phive

The Phar Installation and Verification Environment (PHIVE)
https://phar.io
BSD 3-Clause "New" or "Revised" License
581 stars 45 forks source link

Follow redirects before getting PharVersion #302

Open heiglandreas opened 3 years ago

heiglandreas commented 3 years ago

Currently getPharVersion tries to get the actual PHAR-Version from the provided URL.

If one uses a service that resolves a certain version-constraint and then redirects to the last version matching that constraint the provided URL might not match the regular expressions in that function and result in an inabillity to install the tool.

Either we need to make these regexes much mor elax or resolve the regex after following all redirects to the final download URL and then apply those regexes to that final URL.

Concrete case is that I'm not able to install via phive install "https://api.getlatestassets.com/github/Behat/Behat/behat.phar?version=^3.0" which resolves to https://github.com/Behat/Behat/releases/download/v3.8.1/behat.phar

heiglandreas commented 3 years ago

The issue seems also to be that the URL https://github.com/Behat/Behat/releases/download/v3.8.1/behat.phar also does not match the regex as the regex exptects either *-major.minor.patch* or /major.minor.patch/. But the /v3.8.1/ doesn't match either...

theseer commented 3 years ago

sigh