I'm working with the wkhtmltoimage utility which does not support protocol relative URLs such as this: <script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
I need to convert it to: <script src="http://cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
in Ruby. I'm wondering what the most efficient way of finding these type of URLs as I can't figure out how to write a regex for them and then prepend http:
to it.
Thanks in advance.
You can use perl for that :
perl -pi -e 's/src="\/\//src="http:\/\//' *
This statement above will replace all patterns found in a directory.