fix mobile browser view
Sonarqube Scanner / Build and analyze (push) Successful in 1m36s

This commit is contained in:
Florian Zumpe
2026-06-17 16:27:56 +02:00
parent 32f161483d
commit 13770f21e3
5 changed files with 33 additions and 12 deletions
+11 -1
View File
@@ -21,11 +21,21 @@ const UPDATE_METRICS_SQL = `UPDATE routes SET
start_lat=?, start_lon=?, center_lat=?, center_lon=?, min_lat=?, min_lon=?, max_lat=?, max_lon=?,
distance_m=?, elevation_gain_m=?, point_count=?, updated_at=CURRENT_TIMESTAMP WHERE id=?`;
function trimEdgeHyphens(value) {
let start = 0;
let end = value.length;
while (start < end && value[start] === '-') start += 1;
while (end > start && value[end - 1] === '-') end -= 1;
return value.slice(start, end);
}
function slugify(value) {
const normalized = String(value).toLowerCase().normalize('NFKD');
const withoutMarks = normalized.replaceAll(/[\u0300-\u036f]/g, '');
const separated = withoutMarks.replaceAll(/[^a-z0-9]+/g, '-');
const trimmed = separated.replaceAll(/(?:^-+|-+$)/g, '');
const trimmed = trimEdgeHyphens(separated);
return trimmed.slice(0, 80) || `route-${Date.now()}`;
}