Created
February 7, 2014 20:23
-
-
Save dpritchett/8871014 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
# lib/spree/core/permalinks_decorator.rb | |
module Spree | |
module Core | |
module Permalinks | |
# <client> asked to have permalink generation not use the word 'slash' where | |
# a '/' is present. Now we just let Spree generate it (via StringEx fwiw) | |
# and then strip it out. | |
# | |
def self.generate_url_slug(name) | |
slashes = /(-slash|-slash-|slash-)/ | |
name.to_s.to_url.gsub(slashes, '-'). # remove the word slash | |
gsub(/-+/, '-'). # compact repeated slashes to one | |
gsub(/(^-|-$)/, '') # remove leading/trailing slashes | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment