aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/park-editor.mjs13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/park-editor.mjs b/scripts/park-editor.mjs
index 2ccd96d..feeb059 100644
--- a/scripts/park-editor.mjs
+++ b/scripts/park-editor.mjs
@@ -159,6 +159,19 @@ function mergeInto(target, source) {
// ブラウザが古いデータを持っていても、後から足した項目やレコードを消さないようにする。
// 画面になくて編集できないキーは、ディスク側の値を残す。
function mergeMissing(postedList, currentList, canonicalKeys) {
+ // 公園名そのものが文字化けした場合は、ディスク側の名前に戻す
+ const currentNames = currentList.map(recordKey).filter(Boolean);
+ for (const rec of postedList) {
+ const src = rec.properties || rec;
+ for (const key of NAME_KEYS) {
+ const value = src[key];
+ if (typeof value !== "string" || !value.includes(FFFD)) continue;
+ const hits = currentNames.filter((name) => repairValue(value, name) === name);
+ if (hits.length === 1) src[key] = hits[0];
+ break;
+ }
+ }
+
for (const rec of postedList) normalizeRecordKeys(rec, canonicalKeys);
// 同じレコードが重複していたら1つにまとめる