Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

Commit

Permalink
Merge pull request #48 from raykyri/master
Browse files Browse the repository at this point in the history
Handle relative paths correctly
  • Loading branch information
mikesall committed Apr 7, 2015
2 parents 8d4bd15 + 3c96db4 commit 98dce2b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
9 changes: 4 additions & 5 deletions lib/charted.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ module.exports = function(app, charted_root) {

app.use(charted_root + 'get', function (req, res, next) {
var get_url = url.parse(req.url, true).query.url

if (!get_url) {
res.statusCode = 400
res.end('Bad Request: no url provided')
next()
return
}

request(decodeURIComponent(get_url), function (err, resp, body) {
var get_url_full = url.parse(get_url).host ? get_url :
('http://' + req.headers.host + '/' + get_url.replace(/^\//, ''))

request(get_url_full, function (err, resp, body) {
if (err) {
res.statusCode = 400
res.end('Bad Request: ' + err)
Expand All @@ -32,8 +33,6 @@ module.exports = function(app, charted_root) {
res.statusCode = 200
res.end(body)
}

next()
})
})

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chartedjs",
"version": "0.2.0",
"version": "0.2.3",
"description": "A charting library originally created by the Product Science team at Medium",
"main": "lib/charted.js",
"scripts": {
Expand All @@ -22,9 +22,10 @@
"url": "https://github.com/mikesall/charted/issues"
},
"dependencies": {
"less": "1.7.x",
"connect": "^3.3.5",
"express": "4.10.x",
"jshint": "2.5.x",
"less": "1.7.x",
"request": "2.47.x",
"serve-static": "~1.7.2"
},
Expand Down
23 changes: 23 additions & 0 deletions pub/example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"month","example_one","example_two"
"2013-07","2023","5247"
"2013-08","3343","2357"
"2013-09","1222","4395"
"2013-10","1827","2586"
"2013-11","2110","4179"
"2013-12","3344","4450"
"2014-01","18026","4428"
"2014-02","12388","11877"
"2014-03","4374","5214"
"2014-04","3713","4522"
"2014-05","3412","5542"
"2014-06","4847","4832"
"2014-07","7181","6812"
"2014-08","2124","5681"
"2014-09","2165","2332"
"2014-10","1691","1062"
"2014-11","1239","6015"
"2014-12","7706","1421"
"2015-01","5228","4402"
"2015-02","2918","8130"
"2015-03","5067","3160"
"2015-04","8682","4728"
4 changes: 3 additions & 1 deletion pub/scripts/PageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ PageController.prototype.getFullParams = function (chartIndex) {

PageController.prototype.getDefaultTitle = function (chartIndex) {
var series = this.parameters.charts[chartIndex].series
if (series.length === 1) {
if (!series) {
return 'Charted'
} else if (series.length === 1) {
return this.getSeriesName(series[0])
}
var earlierCharts = this.parameters.charts.filter(function (chart, i) {
Expand Down

0 comments on commit 98dce2b

Please sign in to comment.