From 7e5351f3998158fc5181d505b3d7c99965581a6f Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 21 Apr 2021 04:38:37 +0530 Subject: [PATCH] Do not lowercase source extension input Fix warnings in parseExtensionSource in utils.ts Fix add_lib_log in source.sh --- dist/index.js | 6 +++++- src/scripts/ext/source.sh | 3 +-- src/utils.ts | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 75580a9a..04c51854 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2818,6 +2818,9 @@ async function extensionArray(extension_csv) { return extension_csv .split(',') .map(function (extension) { + if (/.+-.+\/.+@.+/.test(extension)) { + return extension; + } return extension .trim() .toLowerCase() @@ -2976,10 +2979,11 @@ exports.customPackage = customPackage; * Function to extension input for installation from source. * * @param extension + * @param prefix */ async function parseExtensionSource(extension, prefix) { // Groups: extension, domain url, org, repo, release - const regex = /(\w+)-(.+:\/\/.+(?:[.:].+)+(?:\/))?([\w.-]+)\/([\w.-]+)@(.+)/; + const regex = /(\w+)-(.+:\/\/.+(?:[.:].+)+\/)?([\w.-]+)\/([\w.-]+)@(.+)/; const matches = regex.exec(extension); matches[2] = matches[2] ? matches[2].slice(0, -1) : 'https://github.com'; return await joins('\nadd_extension_from_source', ...matches.splice(1, matches.length), prefix); diff --git a/src/scripts/ext/source.sh b/src/scripts/ext/source.sh index a575ff7d..ae950b1b 100644 --- a/src/scripts/ext/source.sh +++ b/src/scripts/ext/source.sh @@ -13,8 +13,7 @@ parse_args() { # Function to log if a library is installed add_lib_log() { lib=$1 - output=$2 - if [ "x$output" != "x" ]; then + if check_lib "$lib"; then add_log "${tick:?}" "$lib" "Installed" else add_log "${cross:?}" "$lib" "Could not install $lib" diff --git a/src/utils.ts b/src/utils.ts index 2591c7e2..246589c9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -247,6 +247,9 @@ export async function extensionArray( return extension_csv .split(',') .map(function (extension: string) { + if (/.+-.+\/.+@.+/.test(extension)) { + return extension; + } return extension .trim() .toLowerCase() @@ -443,13 +446,14 @@ export async function customPackage( * Function to extension input for installation from source. * * @param extension + * @param prefix */ export async function parseExtensionSource( extension: string, prefix: string ): Promise { // Groups: extension, domain url, org, repo, release - const regex = /(\w+)-(.+:\/\/.+(?:[.:].+)+(?:\/))?([\w.-]+)\/([\w.-]+)@(.+)/; + const regex = /(\w+)-(.+:\/\/.+(?:[.:].+)+\/)?([\w.-]+)\/([\w.-]+)@(.+)/; const matches = regex.exec(extension) as RegExpExecArray; matches[2] = matches[2] ? matches[2].slice(0, -1) : 'https://github.com'; return await joins(