mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 22:31:15 +00:00
Parse task headers as HTTP headers rather than JSON
This commit is contained in:

committed by
Rowan Manning

parent
ee729d1d55
commit
568e068613
13
route/new.js
13
route/new.js
@@ -16,6 +16,7 @@
|
||||
'use strict';
|
||||
|
||||
const getStandards = require('../data/standards');
|
||||
const httpHeaders = require('http-headers');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
@@ -37,13 +38,11 @@ function route(app) {
|
||||
|
||||
app.express.post('/new', (req, res) => {
|
||||
|
||||
let parsedHeaders = '';
|
||||
|
||||
try {
|
||||
parsedHeaders = JSON.parse(req.body.headers);
|
||||
} catch (e) {
|
||||
console.log(`error parsing headers object: ${req.body.headers}. Ignoring.`);
|
||||
let parsedHeaders;
|
||||
if (req.body.headers) {
|
||||
parsedHeaders = httpHeaders(req.body.headers, true);
|
||||
}
|
||||
console.log(parsedHeaders);
|
||||
|
||||
const newTask = {
|
||||
name: req.body.name,
|
||||
@@ -54,7 +53,7 @@ function route(app) {
|
||||
wait: req.body.wait || undefined,
|
||||
username: req.body.username || undefined,
|
||||
password: req.body.password || undefined,
|
||||
headers: parsedHeaders || undefined,
|
||||
headers: parsedHeaders,
|
||||
hideElements: req.body.hideElements || undefined
|
||||
};
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
const presentTask = require('../../view/presenter/task');
|
||||
const getStandards = require('../../data/standards');
|
||||
const httpHeaders = require('http-headers');
|
||||
|
||||
module.exports = route;
|
||||
|
||||
@@ -56,12 +57,14 @@ function route(app) {
|
||||
if (err) {
|
||||
return next();
|
||||
}
|
||||
const originalHeaders = req.body.headers;
|
||||
req.body.ignore = req.body.ignore || [];
|
||||
req.body.timeout = req.body.timeout || undefined;
|
||||
req.body.wait = req.body.wait || undefined;
|
||||
req.body.username = req.body.username || undefined;
|
||||
req.body.password = req.body.password || undefined;
|
||||
req.body.hideElements = req.body.hideElements || undefined;
|
||||
req.body.headers = httpHeaders(req.body.headers || '', true);
|
||||
app.webservice.task(req.params.id).edit(req.body, err => {
|
||||
if (err) {
|
||||
task.name = req.body.name;
|
||||
@@ -70,7 +73,7 @@ function route(app) {
|
||||
task.wait = req.body.wait;
|
||||
task.username = req.body.username;
|
||||
task.password = req.body.password;
|
||||
task.headers = req.body.headers;
|
||||
task.headers = originalHeaders;
|
||||
task.hideElements = req.body.hideElements;
|
||||
const standards = getStandards().map(standard => {
|
||||
if (standard.title === task.standard) {
|
||||
|
Reference in New Issue
Block a user