diff options
| author | xq114 <[email protected]> | 2023-02-23 16:51:31 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2023-02-23 16:51:31 +0800 |
| commit | 3a9765192608ee20de3d6448b24bde0095a7274c (patch) | |
| tree | b98f1491b0722532cb054fa0e431d86a41816201 /xmake/modules/private/action/require/impl/utils | |
| parent | 415d9e13ad6fc1431802a00b1697b7178adedd40 (diff) | |
match github name mangling
Diffstat (limited to 'xmake/modules/private/action/require/impl/utils')
| -rw-r--r-- | xmake/modules/private/action/require/impl/utils/url_filename.lua | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/xmake/modules/private/action/require/impl/utils/url_filename.lua b/xmake/modules/private/action/require/impl/utils/url_filename.lua index e17e8673b..9694964ea 100644 --- a/xmake/modules/private/action/require/impl/utils/url_filename.lua +++ b/xmake/modules/private/action/require/impl/utils/url_filename.lua @@ -18,8 +18,27 @@ -- @file url_filename.lua -- --- get filename from url -function main(url) +-- get raw filename +function raw_filename(url) local urlpath = url:split('?', {plain = true})[1] return path.filename(urlpath) end + +-- get filename from github name mangling +function github_filename(url) + if url:find("^https://github.com/[^/]-/[^/]-/archive/") then + local reponame = url:match("^https://github.com/[^/]-/([^/]-)/archive/") + local filename = raw_filename(url) + if filename:find("^v%d") then + filename = filename:match("^v(.+)") + end + if reponame and filename then + return reponame .. "-" .. filename + end + end +end + +-- get filename from url +function main(url) + return raw_filename(url) +end |
