<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,3 @@
-require 'iconv'
 require 'find_by_param'
 class ActiveRecord::Base
   class_inheritable_accessor :permalink_options</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,9 @@
+begin
+  require &quot;active_support/multibyte&quot;
+rescue LoadError
+  require &quot;rubygems&quot;
+  require &quot;active_support/multibyte&quot;
+end
 module Railslove
   module Plugins
     module FindByParam
@@ -59,20 +65,19 @@ You can use for example User.find_by_param(params[:id], args) to find the user b
       
       module SingletonMethods
   
-        # found somewhere on the web.... don't know where... but it's from a clever guy - (done some motifications)
-        def escape(str)
+        # borrowed from http://github.com/henrik/slugalizer ;) thanks henrik http://github.com/henrik
+        def escape(str, separator='-')
           return &quot;&quot; if str.blank? # hack if the str/attribute is nil/blank
-          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
-            s.gsub!(/([^ a-zA-Z0-9_-]+)/n,&quot;&quot;) # and now kill every char not allowed.
-          end
+          re_separator = Regexp.escape(separator)
+          result = ActiveSupport::Multibyte::Handlers::UTF8Handler.normalize(str.to_s, :kd)
+          result.gsub!(/[^\x00-\x7F]+/, '') # Remove non-ASCII (e.g. diacritics).
+          result.gsub!(/[^a-z0-9\-_\+]+/i, separator) # Turn non-slug chars into the separator.
+          result.gsub!(/#{re_separator}{2,}/, separator) # No more than one of the separator in a row.
+          result.gsub!(/^#{re_separator}|#{re_separator}$/, '') # Remove leading/trailing separator.
+          result.downcase!
+          result
         end
-        
+          
 =begin rdoc
 
 Search for an object by the defined permalink column. Similar to find_by_login.
@@ -119,7 +124,7 @@ Accepts an options hash as a second parameter which is passed on to the rails fi
           return unless self.class.column_names.include?(permalink_options[:field].to_s)
           counter = 0
           base_value = escape_and_truncate_for_permalink(read_attribute(permalink_options[:field_to_encode]))
-          permalink_value = &quot;#{base_value}&quot;
+          permalink_value = &quot;#{base_value}&quot;.downcase
           
           conditions = [&quot;#{self.class.table_name}.#{permalink_options[:field]} = ?&quot;, permalink_value]
           unless new_record?
@@ -135,7 +140,7 @@ Accepts an options hash as a second parameter which is passed on to the rails fi
         end
         
         def escape(value)
-          self.class.escape(value)
+          &quot;#{value.respond_to?(&quot;parameterize&quot;) ? value.parameterize : self.class.escape(value)}&quot;
         end
         
         #this escapes and truncates a value.</diff>
      <filename>lib/find_by_param.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ class FindByParamTest &lt; Test::Unit::TestCase
   def test_permalink_should_be_saved
     Post.class_eval &quot;make_permalink :with =&gt; :title&quot;
     post = Post.create(:title=&gt;&quot;hey ho let's go!&quot;)
-    assert_equal post.to_param, &quot;hey-ho-lets-go&quot;
+    assert_equal post.to_param, &quot;hey-ho-let-s-go&quot;
     assert_equal post.permalink, post.to_param
   end
   
@@ -46,7 +46,7 @@ class FindByParamTest &lt; Test::Unit::TestCase
   def test_to_param_should_perpend_id
     Article.class_eval &quot;make_permalink :with =&gt; :title, :prepend_id=&gt;true &quot;
     article = Article.create(:title=&gt;&quot;hey ho let's go!&quot;)
-    assert_equal article.to_param, &quot;#{article.id}-hey-ho-lets-go&quot;
+    assert_equal article.to_param, &quot;#{article.id}-hey-ho-let-s-go&quot;
   end
   
   def test_should_increment_counter_if_not_unique
@@ -65,7 +65,7 @@ class FindByParamTest &lt; Test::Unit::TestCase
   end
   
   def test_escape_should_strip_special_chars
-    assert_equal &quot;hello-nice-dude&quot;, Post.escape(&quot;+*(he/=&amp;l$l&lt;o !ni^?ce-`du&#228;&#246;de;:@&quot;)
+    assert_equal &quot;+-he-l-l-o-ni-ce-duaode&quot;, Post.escape(&quot;+*(he/=&amp;l$l&lt;o !ni^?ce-`du&#228;&#246;de;:@&quot;)
   end
   
   def test_does_not_leak_options</diff>
      <filename>test/find_by_param_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,6 @@ require 'test/unit'
 require 'rubygems'
 require 'active_record'
 require 'active_support'
-require 'iconv'
 require 'find_by_param'
 class ActiveRecord::Base
   class_inheritable_accessor :permalink_options</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6bf84151b8345a292c44879923bad23b74c6bdd4</id>
    </parent>
  </parents>
  <author>
    <name>Michael Bumann</name>
    <email>michael@railslove.com</email>
  </author>
  <url>http://github.com/bumi/find_by_param/commit/5316794891a7d1e24c5b7b7deffbc4c9ec40e653</url>
  <id>5316794891a7d1e24c5b7b7deffbc4c9ec40e653</id>
  <committed-date>2008-10-27T09:32:09-07:00</committed-date>
  <authored-date>2008-10-27T09:32:09-07:00</authored-date>
  <message>rely on active_support/multibyte for slug generation, use Rails parameterize method if present, use escape code from slugalizer (http://github.com/henrik/slugalizer)</message>
  <tree>7335d7b2a1ed0aaabe7b9bbe5950a1e9ec865165</tree>
  <committer>
    <name>Michael Bumann</name>
    <email>michael@railslove.com</email>
  </committer>
</commit>
