Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Bug 1449848 - Bugfix for JSON substitutions (+ prettify) #92

Merged
merged 2 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,15 @@ var remoteAuthentication = function(options, entry) {
'',
'You have the scopes:',
'',
'```',
'{{scopes}}',
'```',
'',
'This request requires you to satisfy this scope expression:',
'',
'```',
'{{required}}',
'```',
].join('\n');
err.details = {
scopes: result.scopes,
Expand Down
2 changes: 1 addition & 1 deletion src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let BuildReportErrorMethod = (method, errorCodes, monitor, cleanPayload) => {
message = message.replace(/{{([a-zA-Z0-9_-]+)}}/g, (text, key) => {
let value = details.hasOwnProperty(key) ? details[key] : text;
if (typeof value !== 'string') {
return JSON.stringify(value, null, 2);
value = JSON.stringify(value, null, 2);
}
// escape the substituted value, so that the markdown rendering cannot be abused
value = escapeMarkdown(value);
Expand Down
8 changes: 4 additions & 4 deletions test/errors_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ suite('api/errors', function() {
let response = JSON.parse(res.response.text);
response.message = response.message.replace(response.requestInfo.time, '<nowish>');
response.requestInfo.time = '<nowish>';
assert(_.isEqual(response, {
assert.deepEqual(response, {
code: 'TooManyFoos',
message: [
'You can only have 3 foos. These foos already exist:',
'[',
'\\[',
' 1,',
' 2,',
' 3',
']',
'\\]',
'----',
'method: toomanyfoos',
'errorCode: TooManyFoos',
Expand All @@ -86,7 +86,7 @@ suite('api/errors', function() {
payload: {foos: [4, 5]},
time: '<nowish>',
},
}));
});
});
});

Expand Down