diff --git a/CHANGELOG.md b/CHANGELOG.md index 499701b..a5c471d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.1 + +- Fix #4 error with non-string id values +- Upgrade dev dependencies to fix tests and pass code coverage check + ## 0.6.0 - Fix #2 setting the `simplestyle` option will now exclude the options from the `` of the KML diff --git a/package.json b/package.json index 3bddbab..746fb00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maphubs/tokml", - "version": "0.6.0", + "version": "0.6.1", "description": "convert geojson to kml", "main": "index.js", "scripts": { diff --git a/tokml.js b/tokml.js index f5dd9fe..45acd6f 100644 --- a/tokml.js +++ b/tokml.js @@ -62,7 +62,7 @@ function feature(options, styleHashesArray) { } var attributes = {} - if (_.id) attributes.id = _.id + if (_.id) attributes.id = _.id.toString(); return ( styleDefinition + tag( @@ -403,28 +403,29 @@ function pairs(_) { } },{"./lib/strxml":2,"./lib/xml-escape":3}],2:[function(require,module,exports){ +/* istanbul ignore file */ // strxml from https://github.com/mapbox/strxml -var esc = require("./xml-escape"); +var esc = require('./xml-escape') -module.exports.attr = attr; -module.exports.tagClose = tagClose; -module.exports.tag = tag; +module.exports.attr = attr +module.exports.tagClose = tagClose +module.exports.tag = tag /** * @param {array} _ an array of attributes * @returns {string} */ function attr(attributes) { - if (!Object.keys(attributes).length) return ""; + if (!Object.keys(attributes).length) return '' return ( - " " + + ' ' + Object.keys(attributes) .map(function (key) { - return key + '="' + esc(attributes[key]) + '"'; + return key + '="' + esc(attributes[key]) + '"' }) - .join(" ") - ); + .join(' ') + ) } /** @@ -433,7 +434,7 @@ function attr(attributes) { * @returns {string} */ function tagClose(el, attributes) { - return "<" + el + attr(attributes) + "/>"; + return '<' + el + attr(attributes) + '/>' } /** @@ -443,45 +444,46 @@ function tagClose(el, attributes) { * @returns {string} */ function tag(el, attributes, contents) { - if (Array.isArray(attributes) || typeof attributes === "string") { - contents = attributes; - attributes = {}; + if (Array.isArray(attributes) || typeof attributes === 'string') { + contents = attributes + attributes = {} } if (Array.isArray(contents)) contents = - "\n" + + '\n' + contents .map(function (content) { - return " " + content; + return ' ' + content }) - .join("\n") + - "\n"; - return "<" + el + attr(attributes) + ">" + contents + ""; + .join('\n') + + '\n' + return '<' + el + attr(attributes) + '>' + contents + '' } },{"./xml-escape":3}],3:[function(require,module,exports){ +/* istanbul ignore file */ // originally from https://github.com/miketheprogrammer/xml-escape var escape = (module.exports = function escape(string, ignore) { - var pattern; + var pattern - if (string === null || string === undefined) return; + if (string === null || string === undefined) return - ignore = (ignore || "").replace(/[^&"<>\']/g, ""); - pattern = "([&\"<>'])".replace(new RegExp("[" + ignore + "]", "g"), ""); + ignore = (ignore || '').replace(/[^&"<>\']/g, '') + pattern = '([&"<>\'])'.replace(new RegExp('[' + ignore + ']', 'g'), '') - return string.replace(new RegExp(pattern, "g"), function (str, item) { - return escape.map[item]; - }); -}); + return string.replace(new RegExp(pattern, 'g'), function (str, item) { + return escape.map[item] + }) +}) var map = (escape.map = { - ">": ">", - "<": "<", - "'": "'", - '"': """, - "&": "&", -}); + '>': '>', + '<': '<', + "'": ''', + '"': '"', + '&': '&' +}) },{}]},{},[1])(1) });