diff --git a/lib/formtastic-slug/slug_input.rb b/lib/formtastic-slug/slug_input.rb index 71f7539..a6e4dd0 100644 --- a/lib/formtastic-slug/slug_input.rb +++ b/lib/formtastic-slug/slug_input.rb @@ -51,7 +51,7 @@ class SlugInput < Formtastic::Inputs::StringInput var setSlug = function(text) { var i, k; - var originalSlug = text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/, ''); + var originalSlug = text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/, ''); var newSlug = originalSlug; var index = 0;