Skip to content

Commit

Permalink
Directly require escapeHeaderAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Nov 4, 2024
1 parent 0330283 commit 90a9361
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const Hoek = require('@hapi/hoek');
const EscapeHeaderAttribute = require('@hapi/hoek/escapeHeaderAttribute');


const internals = {
Expand Down Expand Up @@ -275,14 +275,14 @@ exports.unauthorized = internals.statusError(401, (message, scheme, attributes)

if (attributes) {
if (typeof attributes === 'string') {
stringified += Hoek.escapeHeaderAttribute(attributes);
stringified += EscapeHeaderAttribute(attributes);
}
else {
stringified += Object.keys(attributes).map((name) => {

const value = attributes[name] ?? '';

return `${name}="${Hoek.escapeHeaderAttribute(value.toString())}"`;
return `${name}="${EscapeHeaderAttribute(value.toString())}"`;
})
.join(', ');
}
Expand All @@ -293,7 +293,7 @@ exports.unauthorized = internals.statusError(401, (message, scheme, attributes)
stringified += ', ';
}

stringified += `error="${Hoek.escapeHeaderAttribute(message)}"`;
stringified += `error="${EscapeHeaderAttribute(message)}"`;
}
else {
decorate.isMissing = true;
Expand Down

0 comments on commit 90a9361

Please sign in to comment.