nosdav / pastebin

NosDAV pastebin
https://nosdav.github.io/pastebin/
MIT License
8 stars 1 forks source link

Suggesting a variable name change from userHex to userPublicKey #2

Closed melvincarvalho closed 1 year ago

melvincarvalho commented 1 year ago

I've reviewed the code in the main HTML file and would like to suggest a variable name change to improve code readability and understanding.

Current variable name: userHex Suggested variable name: userPublicKey

The reason for this change is that the variable represents the public key of the user, and naming it userPublicKey would make the code more self-explanatory and easier to understand.

Here's the code snippet with the suggested change:


// Before change
var userHex, filename, contentType, path;
...
async function generateAuthorizationHeader(pubkey) {
  ...
  return `Nostr ${btoa(JSON.stringify(signedEvent))}`
}
...
console.log(`Logged in with public key: ${userHex}`)
...
const text = fileContent.value
var authorization = await generateAuthorizationHeader(userHex)
...

// After change
var userPublicKey, filename, contentType, path;
...
async function generateAuthorizationHeader(pubkey) {
  ...
  return `Nostr ${btoa(JSON.stringify(signedEvent))}`
}
...
console.log(`Logged in with public key: ${userPublicKey}`)
...
const text = fileContent.value
var authorization = await generateAuthorizationHeader(userPublicKey)
...