Skip to content

Commit

Permalink
correction de l'authentification sur la Bibliothèque Municipale de Lyon.
Browse files Browse the repository at this point in the history
Fixes #181
  • Loading branch information
lovasoa committed Jan 3, 2024
1 parent 4cd8c42 commit f3a240c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ophirofox/content_scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function ophirofoxEuropresseLink(keywords) {
*/
function permissionForPartner({ AUTH_URL }) {
const auth_url_host = new URL(AUTH_URL).hostname.split('.');
const all_permissions = [...manifest.optional_permissions, ...manifest.permissions];
const all_permissions = [...manifest.permissions, ...manifest.optional_permissions];
let { permission, match_length } = all_permissions.reduce((best, permission) => {
let permission_host = "";
try {
Expand All @@ -120,9 +120,10 @@ function permissionForPartner({ AUTH_URL }) {
if (match_length > best.match_length) {
return { permission, match_length };
} else return best;
}, { permission: "", match_length: 0 });
// match at least the top level domain
if (match_length < 2) throw new Error(`No permission found for ${AUTH_URL}`);
}, { permission: "", match_length: -1 });
if (match_length < 2) { // no match for the top level domain
console.log(`No permission found for ${AUTH_URL}, will return the first URL permission (${permission})`);
}
return permission;
}

Expand Down

0 comments on commit f3a240c

Please sign in to comment.