Skip to content

Commit dbc7432

Browse files
authored
Small cleanup to canonicalization routines (JuliaPackaging#148)
1 parent 96871ea commit dbc7432

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/wizard/obtain_source.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
using ProgressMeter
22

3-
const repo_regex = r"(https:\/\/)?github.com\/([^\/]+)\/([^\/]+)\/?$"
43

4+
"""
5+
Canonicalize a GitHub repository URL
6+
"""
57
function canonicalize_source_url(url)
8+
repo_regex = r"(https:\/\/)?github.com\/([^\/]+)\/([^\/]+)\/?$"
9+
610
m = match(repo_regex, url)
711
if m !== nothing
812
_, user, repo = m.captures
@@ -202,9 +206,11 @@ function step1(state::WizardState)
202206
println(state.outs)
203207
end
204208

205-
const blob_regex = r"(https:\/\/)?github.com\/([^\/]+)\/([^\/]+)\/blob\/([^\/]+)\/(.+)"
206-
209+
"""
210+
Canonicalize URL to a file within a GitHub repo
211+
"""
207212
function canonicalize_file_url(url)
213+
blob_regex = r"(https:\/\/)?github.com\/([^\/]+)\/([^\/]+)\/blob\/([^\/]+)\/(.+)"
208214
m = match(blob_regex, url)
209215
if m !== nothing
210216
_, user, repo, ref, filepath = m.captures
@@ -241,7 +247,7 @@ function obtain_binary_deps(state::WizardState)
241247
print(state.outs, "> ")
242248
url = readline(state.ins)
243249
println(state.outs)
244-
canon_url = canonicalize_url(url)
250+
canon_url = canonicalize_file_url(url)
245251
if url != canon_url
246252
print(state.outs, "The entered URL has been canonicalized to\n")
247253
printstyled(state.outs, canon_url, bold=true)

0 commit comments

Comments
 (0)