My projects is working fine with all functional and unit test passing but when I pass the solution link to FCC the below tests fail.
If the number is invalid, returned will be `invalid number’
If both the unit and number are invalid, returned will be ‘invalid number and unit’
Reason:
The below tests being passed by FCC fail.
async getUserInput => {
try {
const data = await $.get(
getUserInput('url') + '/api/convert?input=1//2gal'
);
assert(data.error === 'invalid number' || data === 'invalid number');
} catch (xhr) {
throw new Error(xhr.responseText || xhr.message);
}
};
async getUserInput => {
try {
const data = await $.get(
getUserInput('url') + '/api/convert?input=1//2min'
);
assert(
data.error === 'invalid number and unit' ||
data === 'invalid number and unit'
);
} catch (xhr) {
throw new Error(xhr.responseText || xhr.message);
}
};
I found out that what my input variable receives with the below code is 1/2gal and 1/2min respectively.
No matter the number of consecutive slashes I add in the URL, it still resolves to 1/2gal
app.route('/api/convert')
.get(function (req, res){
let input = req.query.input;
}
However if I pass this example through my app and click convert, it returns the correct result, “invalid number”
Please help.
Your project link(s)
solution: https://rough-volcano-starburst.glitch.me
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36
.
Challenge: Metric-Imperial Converter
Link to the challenge: