I have a method in my rails application that saves an image from the og: image url.
def photo_from_url(url) if !Nokogiri::HTML(open(url)).css("meta[property='og:image']").blank? photo_url = Nokogiri::HTML(open(url)).css("meta[property='og:image']").first.attributes["content"] self.photo = URI.parse(photo_url) self.save end end
This works in most cases, unless the URL of the image includes a number starting with 0, for example http://ad009cdnb.website.com/rest-of-url
In these cases, I get an illegal octal digital error.
How can I stop the method from thinking that any numbers starting from zero are base-8?
umezo source share