Javascript clientside and nodejs library for making friendly URLs by stripping out non latin chars, as well as converting chars in different languages to their latin counterparts.
Using it in a browser is quite simple:
friendly('like this') //=> "like-this"
friendly().url('or like that дада') //=> "or-like-that-dada"
// or something more interesing like that:
var boom = new friendly();
boom.alphabets //=> collection of alphabets and rules
boom.trimNonLatinChars('love!me') //=> 'love-me'
boom.convertToLatin(str) //=> converts non Latin chars using alphabets (cyrilic and german chars are supported by default). ex. 'Привет' -> 'Privet'
boom.url(str) /=>
boom.toString() /=> identical to url
For Nodejs there two ways to install the thingy, NPM is one of them:
$ npm install friendlyjs
Git clone is another one:
$ git clone git@github.com:ludopoli/friendlyjs.git
And then just let the node know about it:
var friendly = require('friendlyjs') // npm
var friendly = require('./friendly.js') // manual install
If you want to use the thing in the browser, well, just reference the file, this will create a 'friendly' variable in the global score.
is as easy as:
var boom = new friendly();
boom.alphabets.sibirian = "^-a,@-o,f-j";
boom.convertToLatin('love^me@') //=> 'loveameo'
boom.url('lov e^me@') /=> 'lov-eameo'
- Vladimir Slavin - vladimirslavin@gmail.com - nakedslavin
- Dietrich Baenziger - baenziger@gmail.com - baenziger
Copyright (c) 2011 Ludopoli <hello@ludopoli.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.