0.01
No commit activity in last 3 years
No release in over 3 years
Extends ruby "String" class with "urlize" method which converts string to friendly url. It removes all characters that couldn't be used in url and replaces spaces/underscores with dashes. In addition it transliterate string using I18n library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1.9
~> 2.9

Runtime

~> 0.5
 Project Readme

String Urlize Build Status Dependency Status

Extends ruby String class with urlize method which converts string to friendly url. It removes all characters that couldn't be used in url and replaces spaces/underscores with dashes. In addition it transliterate string using I18n library.

Installation

gem install string-urlize

In Rails 3, add this to your Gemfile and run the bundle command.

gem "string-urlize"

Usage

'my cool string'.urlize # => my-cool-string
:foo_symbol.to_s.urlize # => foo-symbol

Examples:

string url
Lorem ipsum dolor sit amet lorem-ipsum-dolor-sit-amet
CamelCase camel-case
a lot of spaces a-lot-of-spaces
special !@#$%^&*()<>,./?\ \| symbols special-symbols
underscored_string underscored-string
string with-dashes string-with-dashes
ÈÉÊË eeee
òóôõöø oooooo

Transliteration

Transliteration powered by I18n library and enabled by default. So you could provide locale to the urlize method:

'Jürgen'.urlize                 # => "jurgen"
'Jürgen'.urlize(:locale => :de) # => "juergen"

or disable transliteration at all:

'Jürgen'.urlize(:transliterate => false) # => 'jürgen' in ruby 1.9 and 'jrden' in ruby 1.8.7