Guest User

Untitled

a guest
Apr 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. module Extensions #:nodoc:
  2. module CoreExtensions #:nodoc:
  3. module StringExtensions #:nodoc:
  4.  
  5. def convert_relative_to_absolute(domain)
  6. regexes = [/href="(.*?)"/mis,/src="(.*?)"/mis]
  7. this = self
  8. regexes.each do |search|
  9. results = search.match(this)
  10. results.captures.each{|found| this = this.gsub(found,"#{domain}#{found}") } if results && results.captures
  11. end
  12. return this
  13. end
  14.  
  15. end
  16. end
  17. end
Add Comment
Please, Sign In to add comment