Return the empty string when calling toOSM() on entities with test IDs

This commit is contained in:
Thomas Petillon
2020-04-11 16:26:17 +02:00
parent fab6dfa3dd
commit 7a1d08f80e
2 changed files with 12 additions and 2 deletions
+7 -2
View File
@@ -36,7 +36,11 @@ osmEntity.id.fromOSM = function(type, id) {
osmEntity.id.toOSM = function(id) {
return id.slice(1);
var match = id.match(/^[cnwr](-?\d+)$/);
if (match) {
return match[1];
}
return '';
};
@@ -129,7 +133,8 @@ osmEntity.prototype = {
isNew: function() {
return this.osmId() < 0;
var osmId = osmEntity.id.toOSM(this.id);
return osmId.length === 0 || osmId[0] === '-';
},