Skip to content

Instantly share code, notes, and snippets.

@lucagrulla
Created March 14, 2012 11:13
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 lucagrulla/2035822 to your computer and use it in GitHub Desktop.
Save lucagrulla/2035822 to your computer and use it in GitHub Desktop.
sanitize Windows file url for the web
image_path = "\images\foo\myimage.png"
image_path = image_path.dump.gsub(/\\\\/,"/").gsub("\"", "")
#total crazyness to cope with windows cut&paste url with backslashes instead of forward slashes:we convert to / just to avoid troubles...
#cover scenarios where Windows users find where a file is using windows explorer and copy the location from there(therefore with backslashes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment