diff options
author | Daniel Silva <daniel.silva@flipside.org> | 2014-10-10 17:55:39 +0100 |
---|---|---|
committer | Daniel Silva <daniel.silva@flipside.org> | 2014-10-10 17:59:06 +0100 |
commit | 971f5d4864038637bb9b7c828cd64dd29866d744 (patch) | |
tree | b5d00b3d5cd84a8a9548b70f6733a290a136bf9f | |
parent | 2219290824c437564337f515d4b9daea12529d72 (diff) |
Fix problem with branch names.
Branch names that contained slashes like feature/whatever were not parsed properly.
-rwxr-xr-x | jekyll-hook.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/jekyll-hook.js b/jekyll-hook.js index 1094f07..5f2453a 100755 --- a/jekyll-hook.js +++ b/jekyll-hook.js @@ -1,4 +1,4 @@ -#!/usr/bin/env node +//#!/usr/bin/env node var config = require('./config.json'); var fs = require('fs'); @@ -32,25 +32,30 @@ app.use(express.bodyParser({ err.status = 403; throw err; } + + req.request_verified = true; } })); // Receive webhook post -app.post('/hooks/jekyll/:branch', function(req, res) { - +app.post('/hooks/jekyll/*', function(req, res) { + // Prevent non verified request from reaching this. + if (!req.request_verified) { + return res.status(403).send('The request could not be verified.'); + } // Close connection res.send(202); // Queue request handler tasks.defer(function(req, res, cb) { var data = req.body; - var branch = req.params.branch; + var branch = req.params[0]; var params = []; // Parse webhook data for internal variables data.repo = data.repository.name; - data.branch = data.ref.split('/')[2]; + data.branch = data.ref.replace('refs/heads/', ''); data.owner = data.repository.owner.name; // End early if not permitted account |