Skip to content

Commit

Permalink
Make oss author lookup case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Sep 26, 2024
1 parent 9d06742 commit 0b4a79c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/assets/js/oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var data = {
packages: { }
};

var authors = { };

fetch('https://raw.githubusercontent.com/devlooped/nuget/refs/heads/main/nuget.json')
.then(response => {
// Check if the response is successful
Expand All @@ -20,14 +22,19 @@ fetch('https://raw.githubusercontent.com/devlooped/nuget/refs/heads/main/nuget.j
})
.then(json => {
data = json;
// make authors lowercase for case-insensitive lookup
authors = Object.keys(data.authors).reduce((acc, key) => {
acc[key.toLowerCase()] = data.authors[key];
return acc;
}, {});
setBusy(false);
});

async function lookupAccount() {
setBusy(true);
setError('');
document.getElementById('data').innerHTML = '';
var account = document.getElementById('account').value;
var account = document.getElementById('account').value.toLowerCase();
console.log('Looking up account: ' + account);

if (account === '') {
Expand All @@ -36,11 +43,11 @@ async function lookupAccount() {
return;
}

if (data.authors[account] === undefined) {
if (authors[account] === undefined) {
document.getElementById('unsupported').style.display = '';
document.getElementById('supported').style.display = 'none';
} else {
const repositories = data.authors[account].sort().map(repo => ({
const repositories = authors[account].sort().map(repo => ({
repo: repo,
packages: Object.entries(data.packages[repo])
.map(([id, downloads]) => ({
Expand Down

0 comments on commit 0b4a79c

Please sign in to comment.