Skip to content

Commit

Permalink
Added filetype option and added support for using '~' as home path in…
Browse files Browse the repository at this point in the history
… command
  • Loading branch information
jo1gi committed Apr 7, 2021
1 parent b524aaf commit abf59d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/openurl.cr
Expand Up @@ -5,7 +5,8 @@ require "./args"
tests = {
"protocol" => /^[^:]+/,
"domain" => /(?<=:\/\/)[^\/]+/,
"last_file" => /[^\/]+$/
"last_file" => /[^\/]+$/,
"filetype" => /(?<=\.)[^\.\/]+$/
}

# Tests a url on a specific regex parameter from `tests`
Expand Down Expand Up @@ -76,4 +77,9 @@ split = result.split(' ')
command = split[0]
args = split[1..]
args.push(opts.url)
(0..args.size-1).each do |i|
if args[i][0] == '~'
args[i] = ENV["HOME"] + args[i][1..]
end
end
Process.run(command, args: args)

0 comments on commit abf59d8

Please sign in to comment.