mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Use stricter regex for localized field key (closes #2658)
Now it will no longer match `old_name`
This commit is contained in:
@@ -209,11 +209,11 @@ iD.ui.preset.localized = function(field, context) {
|
||||
|
||||
input.value(tags[field.key] || '');
|
||||
|
||||
var postfixed = [];
|
||||
for (var i in tags) {
|
||||
var m = i.match(new RegExp(field.key + ':([a-zA-Z_-]+)$'));
|
||||
if (m && m[1]) {
|
||||
postfixed.push({ lang: m[1], value: tags[i]});
|
||||
var postfixed = [], k, m;
|
||||
for (k in tags) {
|
||||
m = k.match(/^(.*):([a-zA-Z_-]+)$/);
|
||||
if (m && m[1] === field.key && m[2]) {
|
||||
postfixed.push({ lang: m[2], value: tags[k] });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,15 @@ describe('iD.ui.preset.localized', function() {
|
||||
happen.once(selection.selectAll('.localized-lang').node(), {type: 'change'});
|
||||
});
|
||||
|
||||
it("ignores similar keys like `old_name`", function() {
|
||||
var localized = iD.ui.preset.localized(field, {});
|
||||
selection.call(localized);
|
||||
localized.tags({'old_name:de': 'Value'});
|
||||
|
||||
expect(selection.selectAll('.localized-lang').empty()).to.be.ok;
|
||||
expect(selection.selectAll('.localized-value').empty()).to.be.ok;
|
||||
});
|
||||
|
||||
it("removes the tag when the language is emptied", function() {
|
||||
var localized = iD.ui.preset.localized(field, {});
|
||||
selection.call(localized);
|
||||
|
||||
Reference in New Issue
Block a user