Code Monkey home page Code Monkey logo

webalize's Introduction

Webalize text/url utils

Collection of text and url processing functions


API

Functions

looksLikeFile(urlParam)boolean

Filters file urls from template urls

webalize(str)string
camelcaseToWebalized(str)string

Makes url nice.

toCamelCase(str, [withDiacritics])string

Makes camelcase from nice url (reverse to camelcaseToWebalized)

webalizeChunks(string, [separator])string

Makes nice url from template path

camelCaseChunks(string, [separator])string

Parses url path to template path

asTemplateUrl(path, urlParam, homeView, [notFoundView])string | null

Makes template path when possible, otherwise returns notFoundView

withParams(urlParam)string

Adds parameter to querystring or hash

replaceDiacritics(str)string

Replaces all diacritics

looksLikeFile(urlParam) ⇒ boolean

Filters file urls from template urls

Kind: global function

Param Type
urlParam any

Example

url.looksLikeFile('/assets/img/some_image.png?v=132') // === true

webalize(str) ⇒ string

Kind: global function

Param Type
str string

Example

url.webalize('-Ňějaký čupr', true) // === 'nejaky-cupr'

camelcaseToWebalized(str) ⇒ string

Makes url nice.

Kind: global function

Param Type Description
str string Should not start with lowercase character

Example

url.camelcaseToWebalized('helloWorld') // === 'hello-world'

toCamelCase(str, [withDiacritics]) ⇒ string

Makes camelcase from nice url (reverse to camelcaseToWebalized)

Kind: global function

Param Type Default
str string
[withDiacritics] boolean false

Example

url.toCamelCase('ŇěJaký čupr', true) // === 'nejakyCupr'

webalizeChunks(string, [separator]) ⇒ string

Makes nice url from template path

Kind: global function

Param Type Default
string string
[separator] string "'/'"

Example

url.webalizeChunks('/blahBlah/haHa'), '/blah-blah/ha-ha'

camelCaseChunks(string, [separator]) ⇒ string

Parses url path to template path

Kind: global function

Param Type Default
string string
[separator] string "'/'"

Example

url.camelCaseChunks('/blah-blah/ha-ha') // === '/blahBlah/haHa'

asTemplateUrl(path, urlParam, homeView, [notFoundView]) ⇒ string | null

Makes template path when possible, otherwise returns notFoundView

Kind: global function

Param Type Default Description
path string path part of url
urlParam string whole url
homeView any home view template for / path
[notFoundView] any

withParams(urlParam) ⇒ string

Adds parameter to querystring or hash

Kind: global function

Param Type Description
urlParam string
options.query Object | null querystring object (null removes query)
options.hash Object | null hash object (null removes hash)

Example

const res = url.withParams('http://www.google.com?foo=1&bar=&x=hello', { query: { x: 1, y: 2 } });
assert.equal(res, 'http://www.google.com/?foo=1&bar=&x=1&y=2');

replaceDiacritics(str) ⇒ string

Replaces all diacritics

Kind: global function

Param Type
str string

webalize's People

Contributors

davidmenger avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.