1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 14:11:59 +01:00

Valid PS compare fix for PS under 3 chars

Fix to allow stations with a PS less than 3 characters to be IDed when PS validity checked
This commit is contained in:
Adam Wisher
2025-07-22 17:51:07 +01:00
committed by GitHub
parent cd9bbaee87
commit 9b3593bc02

View File

@@ -197,6 +197,9 @@ function validPsCompare(rdsPs, stationPs) {
// Iterate through all tokens and check if any token yields at least three valid (non "_" ) matches.
for (let token of psTokens) {
// If total non "_" length of token is less than 3, allow match based on that length instead
const tokenLength = token.replace(/_/g, "").length;
const minMatchLen = tokenLength > 2 ? 3 : tokenLength;
// If the token's length does not match the standardized rdsPs length, skip this token.
if (token.length !== standardizedRdsPs.length) continue;
@@ -208,7 +211,7 @@ function validPsCompare(rdsPs, stationPs) {
matchCount++;
}
}
if (matchCount >= 3) {
if (matchCount >= minMatchLen) {
return true;
}
}
@@ -393,4 +396,4 @@ function deg2rad(deg) {
module.exports = {
fetchTx
};
};