Skip to content

Instantly share code, notes, and snippets.

@timmyc
Created November 12, 2009 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmyc/233321 to your computer and use it in GitHub Desktop.
Save timmyc/233321 to your computer and use it in GitHub Desktop.
module Extensions #:nodoc:
module CoreExtensions #:nodoc:
module StringExtensions #:nodoc:
def convert_relative_to_absolute(domain)
regexes = [/href="(.*?)"/mis,/src="(.*?)"/mis]
this = self
regexes.each do |search|
results = search.match(this)
results.captures.each{|found| this = this.gsub(found,"#{domain}#{found}") } if results && results.captures
end
return this
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment