From 38b493c8e0650bf993ce4d264c59e1e051671fbb Mon Sep 17 00:00:00 2001 From: Gokhan Doslu Date: Fri, 6 Jan 2017 21:59:33 +0300 Subject: [PATCH] Fixed issue about encoding --- index.js | 6 +++--- package.json | 2 +- test.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 978952e..8a947c6 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,7 @@ function valueProcessors(val) { } } -module.exports = function(cb, dataSourceURL = 'http://www.tcmb.gov.tr/kurlar/today.xml') { // XML Source for Indicative Exchange Rates Announced by the Central Bank of Turkey +module.exports = function(cb, dataSourceURL = 'http://www.tcmb.gov.tr/kurlar/today.xml', encoding = 'UTF-8') { // XML Source for Indicative Exchange Rates Announced by the Central Bank of Turkey var options = { url: dataSourceURL, @@ -51,7 +51,7 @@ module.exports = function(cb, dataSourceURL = 'http://www.tcmb.gov.tr/kurlar/tod 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.95 Safari/537.36', 'Accept-Language': 'en-US,en;q=0.8,tr;q=0.6', - 'Accept-Charset': 'ISO-8859-9' + 'Accept-Charset': encoding }, }; @@ -63,7 +63,7 @@ module.exports = function(cb, dataSourceURL = 'http://www.tcmb.gov.tr/kurlar/tod return cb('Response code is: ' + response.statusCode, null); } - var xml = iconv.decode(body, 'ISO-8859-9'); + var xml = iconv.decode(body, encoding); if (!xml || xml.search('Tarih_Date') === -1) { return cb('Invalid xml', null); diff --git a/package.json b/package.json index 8268357..d9b03ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tcmb-doviz-kuru", - "version": "2.0.3", + "version": "2.0.4", "description": "Get Indicative Exchange Rates Announced by the Central Bank of Turkey", "main": "index.js", "scripts": { diff --git a/test.js b/test.js index 5656bc3..0f3157b 100644 --- a/test.js +++ b/test.js @@ -16,7 +16,7 @@ function cb(error, data) { console.log(JSON.stringify(data)); } -tcbmDovizKuru(cb, 'http://www.tcmb.gov.tr/kurlar/200501/17012005.xml'); +tcbmDovizKuru(cb); // FIXME // describe('tcbmDovizKuru', function () {