Skip to content

Commit

Permalink
Do not lowercase source extension input
Browse files Browse the repository at this point in the history
Fix warnings in parseExtensionSource in utils.ts

Fix add_lib_log in source.sh
  • Loading branch information
shivammathur committed Apr 20, 2021
1 parent fe944a1 commit 7e5351f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/scripts/ext/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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<string> {
// 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(
Expand Down

0 comments on commit 7e5351f

Please sign in to comment.