Skip to content

Instantly share code, notes, and snippets.

@Echos
Last active August 29, 2015 14:13
Show Gist options
  • Save Echos/b24d29378f9aba6e976e to your computer and use it in GitHub Desktop.
Save Echos/b24d29378f9aba6e976e to your computer and use it in GitHub Desktop.
#!/bin/bash
uri=$1
checkuri(){
schema=`echo $1 | sed -e 's,^\(.*://\).*,\1,g'`
url=`echo ${1/$schema/}`
if [[ $url = *@* ]]; then
userpass=`echo $url | sed -e 's,^\(.*\)@.*,\1,g'`
if [[ $userpass = *:* ]];then
user=`echo $userpass | sed -e 's,^\(.*\):.*,\1,g'`
pass=`echo $userpass | sed -e 's,^.*:\(.*\),\1,g'`
else
user=$userpass
fi
fi
hostport="$(echo ${url/$userpass@/} | cut -d/ -f1)"
if [[ $hostport = *:* ]]; then
host=`echo $hostport | sed -e 's,^\(.*\):.*,\1,g'`
port=`echo $hostport | sed -e 's,^.*:\(.*\),\1,g'`
else
host=$hostport
fi
path="$(echo $url | grep / | cut -d/ -f2-)"
echo " sche: $schema"
echo " user: $user"
echo " pass: $pass"
echo " host: $host"
echo " port: $port"
echo " path: $path"
schema=""
user=""
pass=""
host=""
port=""
path=""
}
uris=( \
"mongodb://heroku_app111111_A:[email protected]:1233545/heroku_app11111111" \
"mongodb://heroku_app111111_A:[email protected]:1233545/" \
"mongodb://heroku_app111111_A:[email protected]/heroku_app11111111" \
"mongodb://[email protected]:1233545/heroku_app11111111" \
"mongodb://:[email protected]:1233545/heroku_app11111111" \
"mongodb://heroku_app111111_A:[email protected]/" \
"ongodb://[email protected]:1233545/" \
"mongodb://[email protected]/heroku_app11111111" \
"mongodb://:[email protected]:1233545/" \
"mongodb://:[email protected]/heroku_app11111111" \
"mongodb://mongo.mongolab.com:1233545/heroku_app11111111" \
"mongodb://[email protected]/" \
"mongodb://:[email protected]/" \
"mongodb://mongo.mongolab.com:1233545/" \
"mongodb://mongo.mongolab.com/heroku_app11111111" \
"mongodb://mongo.mongolab.com/" \
)
for u in ${uris[@]}; do
echo "target: $u"
checkuri $u
done
target: mongodb://heroku_app111111_A:[email protected]:1233545/heroku_app11111111
sche: mongodb://
user: heroku_app111111_A
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port: 1233545
path: heroku_app11111111
target: mongodb://heroku_app111111_A:[email protected]:1233545/
sche: mongodb://
user: heroku_app111111_A
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port: 1233545
path:
target: mongodb://heroku_app111111_A:[email protected]/heroku_app11111111
sche: mongodb://
user: heroku_app111111_A
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port:
path: heroku_app11111111
target: mongodb://[email protected]:1233545/heroku_app11111111
sche: mongodb://
user: heroku_app111111_A
pass:
host: mongo.mongolab.com
port: 1233545
path: heroku_app11111111
target: mongodb://:[email protected]:1233545/heroku_app11111111
sche: mongodb://
user:
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port: 1233545
path: heroku_app11111111
target: mongodb://heroku_app111111_A:[email protected]/
sche: mongodb://
user: heroku_app111111_A
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port:
path:
target: ongodb://[email protected]:1233545/
sche: ongodb://
user: heroku_app111111_A
pass:
host: mongo.mongolab.com
port: 1233545
path:
target: mongodb://[email protected]/heroku_app11111111
sche: mongodb://
user: heroku_app111111_A
pass:
host: mongo.mongolab.com
port:
path: heroku_app11111111
target: mongodb://:[email protected]:1233545/
sche: mongodb://
user:
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port: 1233545
path:
target: mongodb://:[email protected]/heroku_app11111111
sche: mongodb://
user:
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port:
path: heroku_app11111111
target: mongodb://mongo.mongolab.com:1233545/heroku_app11111111
sche: mongodb://
user:
pass:
host: mongo.mongolab.com
port: 1233545
path: heroku_app11111111
target: mongodb://[email protected]/
sche: mongodb://
user: heroku_app111111_A
pass:
host: mongo.mongolab.com
port:
path:
target: mongodb://:[email protected]/
sche: mongodb://
user:
pass: aasdhjqhdoiqhwoidhoid
host: mongo.mongolab.com
port:
path:
target: mongodb://mongo.mongolab.com:1233545/
sche: mongodb://
user:
pass:
host: mongo.mongolab.com
port: 1233545
path:
target: mongodb://mongo.mongolab.com/heroku_app11111111
sche: mongodb://
user:
pass:
host: mongo.mongolab.com
port:
path: heroku_app11111111
target: mongodb://mongo.mongolab.com/
sche: mongodb://
user:
pass:
host: mongo.mongolab.com
port:
path:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment