Improve regex in utils.parseVersion

This commit is contained in:
Shivam Mathur 2021-02-05 04:42:33 +05:30
parent 86e1ccdd8d
commit 912f27c42c
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 2 additions and 2 deletions

2
dist/index.js vendored
View File

@ -1121,7 +1121,7 @@ exports.fetch = fetch;
async function parseVersion(version) {
const manifest = 'https://dl.bintray.com/shivammathur/php/php-versions.json';
switch (true) {
case /latest|\d.x/.test(version):
case /^(latest|\d+\.x)$/.test(version):
return JSON.parse(await fetch(manifest))[version];
default:
switch (true) {

View File

@ -69,7 +69,7 @@ export async function fetch(url: string): Promise<string> {
export async function parseVersion(version: string): Promise<string> {
const manifest = 'https://dl.bintray.com/shivammathur/php/php-versions.json';
switch (true) {
case /latest|\d.x/.test(version):
case /^(latest|\d+\.x)$/.test(version):
return JSON.parse(await fetch(manifest))[version];
default:
switch (true) {