github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/url_parse.sh (about) 1 #!/bin/bash 2 3 # The acceptance tests use this script to generate the delete snapshot request URL. 4 5 # extract the protocol 6 proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')" 7 8 # remove the protocol 9 url="$(echo ${1/$proto/})" 10 11 # extract the user (if any) 12 user="$(echo $url | grep @ | cut -d@ -f1)" 13 14 # extract the host and port 15 hostport="$(echo ${url/$user@/} | cut -d/ -f1)" 16 17 # by request host without port 18 host="$(echo $hostport | sed -e 's,:.*,,g')" 19 20 # by request - try to extract the port 21 port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')" 22 23 # extract the path (if any) 24 path="$(echo $url | grep / | cut -d/ -f2-)" 25 26 # echo " url: $url" 27 # echo " proto: $proto" 28 # echo " user: $user" 29 # echo " host: $host" 30 # echo " port: $port" 31 # echo " path: $path" 32 33 echo "$proto$host/api/v0/$path"