Add name2id function
This commit is contained in:
parent
ae11c6b876
commit
24e2268e96
|
@ -6,6 +6,7 @@ const urlParser = require('url')
|
|||
const escapeStringRegexp = require('escape-string-regexp')
|
||||
const markdownInclude = require('markdown-include')
|
||||
const iso6393 = require('iso-639-3')
|
||||
const transliteration = require('transliteration')
|
||||
const regions = require('./regions')
|
||||
const categories = require('./categories')
|
||||
const intlDisplayNames = new Intl.DisplayNames(['en'], {
|
||||
|
@ -15,6 +16,13 @@ const intlDisplayNames = new Intl.DisplayNames(['en'], {
|
|||
|
||||
const utils = {}
|
||||
|
||||
utils.name2id = function (name) {
|
||||
return transliteration
|
||||
.transliterate(name)
|
||||
.replace(/\+/gi, 'Plus')
|
||||
.replace(/[^a-z\d]+/gi, '')
|
||||
}
|
||||
|
||||
utils.code2flag = function (code) {
|
||||
code = code.toUpperCase()
|
||||
switch (code) {
|
||||
|
|
Loading…
Reference in New Issue