Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Mar 16, 2024
1 parent 2559933 commit db1ad98
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions content/path-search.ts
Expand Up @@ -18,16 +18,16 @@ async function* asyncGenerator<T>(array: T[]): AsyncGenerator<T, void, unknown>
}

const ENV = Components.classes['@mozilla.org/process/environment;1'].getService(Components.interfaces.nsIEnvironment)
const Var = Zotero.isWin ? /%([A-Z][A-Z0-9]*)%/ig : /[$]([A-Z][A-Z0-9]*)/ig
const VarRef = Zotero.isWin ? /%([A-Z][A-Z0-9]*)%/ig : /[$]([A-Z][A-Z0-9]*)/ig
function expandVars(name: string, expanded: Record<string, string>): string {
if (typeof expanded[name] !== 'string') {
let more = true
expanded[name] = ENV.get(name) || ''
let more = true
while (more) {
more = false
expanded[name] = expanded[name].replace(Var, (match, inner) => {
expanded[name] = expanded[name].replace(VarRef, (match, varref) => {
more = true
return expandVars(inner, expanded)
return expandVars(varref, expanded)
})
}
}
Expand Down

0 comments on commit db1ad98

Please sign in to comment.