Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion vnc_lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,22 @@

if (match) {
// We have to decode the URL since want the cleartext value
return decodeURIComponent(match[1]);
const value = decodeURIComponent(match[1]);
if (value.toLowerCase() === 'false' || value === '0') {
return false;
}
if (value.toLowerCase() === 'true' || value === '1') {
return true;
}
Comment on lines +121 to +126
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to work since you don't know if the caller wants a Number or Boolean.

I'd suggest adding a typed wrapper so the caller can be clear what it wants. I.e. readBoolQueryVariable().

// Check for integer
if (/^-?\d+$/.test(value)) {
return parseInt(value, 10);
}
// Check for float
if (/^-?\d*\.\d+$/.test(value)) {
return parseFloat(value);
}
return value;
}

return defaultValue;
Expand Down