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
boolean
looksLikeFile(urlParam) ⇒ Filters file urls from template urls
Kind: global function
Param | Type |
---|---|
urlParam | any |
Example
url // === true
string
webalize(str) ⇒ Kind: global function
Param | Type |
---|---|
str | string |
Example
url // === 'nejaky-cupr'
string
camelcaseToWebalized(str) ⇒ Makes url nice.
Kind: global function
Param | Type | Description |
---|---|---|
str | string |
Should not start with lowercase character |
Example
url // === 'hello-world'
string
toCamelCase(str, [withDiacritics]) ⇒ Makes camelcase from nice url (reverse to camelcaseToWebalized)
Kind: global function
Param | Type | Default |
---|---|---|
str | string |
|
[withDiacritics] | boolean |
false |
Example
url // === 'nejakyCupr'
string
webalizeChunks(string, [separator]) ⇒ Makes nice url from template path
Kind: global function
Param | Type | Default |
---|---|---|
string | string |
|
[separator] | string |
"'/'" |
Example
url '/blah-blah/ha-ha'
string
camelCaseChunks(string, [separator]) ⇒ Parses url path to template path
Kind: global function
Param | Type | Default |
---|---|---|
string | string |
|
[separator] | string |
"'/'" |
Example
url // === '/blahBlah/haHa'
string
| null
asTemplateUrl(path, urlParam, homeView, [notFoundView]) ⇒ 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 |
|
string
withParams(urlParam) ⇒ 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;assert;
string
replaceDiacritics(str) ⇒ Replaces all diacritics
Kind: global function
Param | Type |
---|---|
str | string |