Skip to content

Commit

Permalink
Fixed issue about encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
gdoslu committed Jan 6, 2017
1 parent 3413267 commit 38b493c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
},

};
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 38b493c

Please sign in to comment.