Skip to content

Commit

Permalink
fix: use same regex from scoop powershell code to gen cached file name
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Want-ToBelieve committed Oct 27, 2023
1 parent 4c943bc commit 0ff2b7e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ export async function getAppCacheFileName(
version: string,
url: string
): Promise<string> {
const format = (url: string) =>
url.replace(/(http|https):\/\//, '$1_').replace(/\//g, '_')
// @see https://github.com/ScoopInstaller/Scoop/blob/f93028001fbe5c78cc41f59e3814d2ac8e595724/lib/core.ps1#L227C3-L227C3
// function cache_path($app, $version, $url) { "$cachedir\$app#$version#$($url -replace '[^\w\.\-]+', '_')" }
const format = (url: string) => url.replace(/[^\w.-]+/g, '_')

return `${app}#${version}#${format(url)}`
}
Expand Down

0 comments on commit 0ff2b7e

Please sign in to comment.