Created
November 12, 2009 21:49
-
-
Save timmyc/233321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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