Skip to content

Instantly share code, notes, and snippets.

@jebenexer
Created November 1, 2012 23:35
Show Gist options
  • Save jebenexer/3997546 to your computer and use it in GitHub Desktop.
Save jebenexer/3997546 to your computer and use it in GitHub Desktop.
Prompt URL String Creds
require 'uri'
class Login < String
def prompt()
.... ask user for info ....
end
def scan(pattern)
self.prompt()
super
end
end
creds = Login.new('https://user:pass@example.com/secured_file.txt')
print URI.extract(creds)
# returns [nil]
creds = 'https://user:pass@example.com/secured_file.txt'
print URI.extract(creds)
# returns ['https://user:pass@example.com/secured_file.txt']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment