Urlify Functions & Its Implementation

URLify is a simple gem that refines the conversion of UTF-8 strings to ASCII-safe URI strings and enables it to be used as readable URL-segments. After the gem is installed, you can call the URLify function for any UTF-8 string and it will be automatically converted into an ASCII-safe URI string. URLify also has the additional functionality of being able to remove the subtitles in a given input.


‘À’ => ‘A’, ‘Á’ => ‘A’, ‘Â’ => ‘A’, ‘Ã’ => ‘A’, ‘Ä’ => ‘A’, ‘Å’ => ‘AA’, ‘Æ’ => ‘AE’, ‘Ç’ => ‘C’, ‘È’ => ‘E’, ‘É’ => ‘E’, ‘Ê’ => ‘E’, ‘Ë’ => ‘E’, ‘Ì’ => ‘I’, ‘Í’ => ‘I’, ‘Î’ => ‘I’, ‘Ï’ => ‘I’, ‘Ð’ => ‘D’, ‘Ł’ => ‘L’, ‘Ñ’ => ‘N’, ‘Ò’ => ‘O’, ‘Ó’ => ‘O’, ‘Ô’ => ‘O’, ‘Õ’ => ‘O’, ‘Ö’ => ‘O’, ‘Ø’ => ‘OE’, ‘Ù’ => ‘U’, ‘Ú’ => ‘U’, ‘Ü’ => ‘U’, ‘Û’ => ‘U’, ‘Ý’ => ‘Y’, ‘Þ’ => ‘Th’, ‘ß’ => ‘ss’, ‘à’ => ‘a’, ‘á’ => ‘a’, ‘â’ => ‘a’, ‘ã’ => ‘a’, ‘ä’ => ‘a’, ‘å’ => ‘aa’, ‘æ’ => ‘ae’, ‘ç’ => ‘c’, ‘è’ => ‘e’, ‘é’ => ‘e’, ‘ê’ => ‘e’, ‘ë’ => ‘e’, ‘ì’ => ‘i’, ‘í’ => ‘i’, ‘î’ => ‘i’, ‘ï’ => ‘i’, ‘ð’ => ‘d’, ‘ł’ => ‘l’, ‘ñ’ => ‘n’, ‘ń’ => ‘n’, ‘ò’ => ‘o’, ‘ó’ => ‘o’, ‘ô’ => ‘o’, ‘õ’ => ‘o’, ‘ō’ => ‘o’, ‘ö’ => ‘o’, ‘ø’ => ‘oe’, ‘ś’ => ‘s’, ‘ù’ => ‘u’, ‘ú’ => ‘u’, ‘û’ => ‘u’, ‘ū’ => ‘u’, ‘ü’ => ‘u’, ‘ý’ => ‘y’, ‘þ’ => ‘th’, ‘ÿ’ => ‘y’, ‘ż’ => ‘z’, ‘Œ’ => ‘OE’, ‘œ’ => ‘oe’, ‘&’ => ‘and’

Easy Steps To Implement URLify Gem

  1. Go to the Gemfile and add the gem urlify
  2. Exécutez la commande installation groupée
OR In the terminal, run the command gem install urlify

A Demo Of Implementation Of URLify

Here is an example of URLify functionality:
  1. Add gem urlify in your Gemfile
  2. Run bundle install
We can now start using URLify API and their attributes as shown below: URLify .deaccentuate(string) ⇒ Object Removes diacritics from an input string’s characters. .strip_subtitle(string) ⇒ Object Removes everything from a string after the first colon. .urlify(string, separator = “_”) ⇒ Object Converts an input string into a URL-safe string. We can add URLify module to the String class and make deaccentuate, strip_subtitle, urlify as instance method by doing the following: urlify

Les références:

Git Hub : https://github.com/beastaugh/urlify Ruby on Rails Gems : https://dzone.com/articles/10-ruby-on-rails-gems-for-web-development RailsCarma offers end-to-end ruby on rails development solutions that caters to everything from deployment to support and hosting. We put together great ideas & professional coding skills to deliver stable, efficient & successful mobile and web applications for your business. Contactez-nous aujourd'hui for best-in-industry solutions for your business! Sauvegarder Sauvegarder Sauvegarder

Abonnez-vous pour les dernières mises à jour

Articles Similaires

Laissez un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *