Created
February 22, 2012 04:29
-
-
Save quezo/1881382 to your computer and use it in GitHub Desktop.
This file contains 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
def make_safe_url(slug) | |
slug = slug.downcase | |
# strip html | |
slug = slug.gsub(/<\/?[^>]*>/, "") | |
# remove html entities | |
slug = slug.gsub(/[^;\s]+;/, "") | |
# remove non-word chars | |
slug = slug.gsub(/[^\w\s]/, "") | |
# change spaces to dashses | |
slug = slug.gsub(/\s+/, "-") | |
slug | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment