Permalink
Browse files

remove multiple dashes in escaped URL

  • Loading branch information...
bumi committed Aug 16, 2008
1 parent e0953cf commit cd69ee0e262c3d96ba1846b5e797e48a92f05b77
Showing with 2 additions and 1 deletion.
  1. +1 −1 MIT-LICENSE
  2. +1 −0 lib/find_by_param.rb
View
@@ -1,4 +1,4 @@
-Copyright (c) 2007 [name of plugin creator]
+Copyright (c) 2007 [Michael Bumann - Railslove.com]
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -65,6 +65,7 @@ def escape(str)
s = Iconv.iconv('ascii//ignore//translit', 'utf-8', str.dup).to_s
returning str.dup.to_s do |s|
s.gsub!(/\ +/, '-') # spaces to dashes, preferred separator char everywhere
+ s.gsub!(/\-+/,'-') # ----- to -
s.gsub!(/[^\w^-]+/, '') # kill non-word chars except -
s.strip! # ohh la la
s.downcase! # :D

0 comments on commit cd69ee0

Please sign in to comment.