forked from DebaucheryLibrarian/traxxx
Added BaDoink profile scraper. Improved convert wrapper.
This commit is contained in:
@@ -61,7 +61,8 @@ function kgToLbs(kgs) {
|
||||
function convertManyApi(input, to) {
|
||||
const curatedInput = input
|
||||
.replace('\'', 'ft')
|
||||
.replace('"', 'in');
|
||||
.replace(/"|''/, 'in')
|
||||
.replace(/\d+ft\s*\d+\s*$/, match => `${match}in`); // height without any inch symbol
|
||||
|
||||
return Math.round(convertMany(curatedInput).to(to)) || null;
|
||||
}
|
||||
@@ -76,7 +77,9 @@ function convertApi(input, fromOrTo, to) {
|
||||
return convertManyApi(input, fromOrTo);
|
||||
}
|
||||
|
||||
return Math.round(convert(input).from(fromOrTo).to(to)) || null;
|
||||
const inputNumber = Number(typeof input === 'string' ? input.match(/\d+(\.\d+)?/)?.[0] : input);
|
||||
|
||||
return Math.round(convert(inputNumber).from(fromOrTo).to(to)) || null;
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user