Skip to content

Commit

Permalink
fix(api): verify www-authenticate header exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed Oct 19, 2021
1 parent a522a71 commit cd78efe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/src/util/process.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ module.exports.isValidURL = async ({ auth = false, type, url }) => {

return isValid;
} catch (error) {
const authType =
error?.response?.headers['www-authenticate'].toLowerCase().split(' ')[0] || false;
if (authType === 'digest' && !auth) return this.isValidURL({ auth: authType, type, url });
if (error?.response?.headers['www-authenticate']) {
const authType =
error.response.headers['www-authenticate'].toLowerCase().split(' ')[0] || false;
if (authType === 'digest' && !auth) return this.isValidURL({ auth: authType, type, url });
}
error.message = `url validation error: ${error.message}`;
console.error(error);
return false;
Expand Down

0 comments on commit cd78efe

Please sign in to comment.