Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #42 from hillct/master

Fixed trailing slash URL bug and relative path issues
  • Loading branch information...
commit c67a66557e1bc15aeb902d4e65a76e2977b605ae 2 parents 76f900b + 41e7dd3
@mansilladev mansilladev authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 app.js
View
7 app.js
@@ -70,7 +70,7 @@ db.on("error", function(err) {
// Load API Configs
//
var apisConfig;
-fs.readFile('public/data/apiconfig.json', 'utf-8', function(err, data) {
+fs.readFile(__dirname +'/public/data/apiconfig.json', 'utf-8', function(err, data) {
if (err) throw err;
apisConfig = JSON.parse(data);
if (config.debug) {
@@ -620,7 +620,7 @@ app.dynamicHelpers({
if (!req.params.api) {
pathName = req.url.replace('/','');
// Is it a valid API - if there's a config file we can assume so
- fs.stat('public/data/' + pathName + '.json', function (error, stats) {
+ fs.stat(__dirname + '/public/data/' + pathName + '.json', function (error, stats) {
if (stats) {
req.params.api = pathName;
}
@@ -647,7 +647,7 @@ app.dynamicHelpers({
},
apiDefinition: function(req, res) {
if (req.params.api) {
- var data = fs.readFileSync('public/data/' + req.params.api + '.json');
+ var data = fs.readFileSync(__dirname + '/public/data/' + req.params.api + '.json');
return JSON.parse(data);
}
}
@@ -692,6 +692,7 @@ app.post('/upload', function(req, res) {
// API shortname, all lowercase
app.get('/:api([^\.]+)', function(req, res) {
+ req.params.api=req.params.api.replace(/\/$/,'');
res.render('api');
});
Please sign in to comment.
Something went wrong with that request. Please try again.