How to use the slug.charmap function in slug

To help you get started, we’ve selected a few slug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getgridea / gridea / src / helpers / slug.ts View on Github external
* Custom mode of rfc3986 without unicode symbols
 */
slug.defaults.modes['rfc3986-non-unicode'] = {
  replacement: '-', // replace spaces with replacement
  symbols: false, // replace unicode symbols or not
  remove: /[.]/g, // (optional) regex to remove characters
  lower: true, // result in lower case
  charmap: slug.charmap, // replace special characters
  multicharmap: slug.multicharmap, // replace multi-characters
}

slug.defaults.modes['rfc3986-non-unicode-with-dots'] = {
  replacement: '-', // replace spaces with replacement
  symbols: false, // replace unicode symbols or not
  lower: true, // result in lower case
  charmap: slug.charmap, // replace special characters
  multicharmap: slug.multicharmap, // replace multi-characters
}

slug.defaults.modes['rfc3986-non-unicode-with-dots-no-lower'] = {
  replacement: '-', // replace spaces with replacement
  symbols: false, // replace unicode symbols or not
  lower: false, // result in lower case
  charmap: slug.charmap, // replace special characters
  multicharmap: slug.multicharmap, // replace multi-characters
}

slug.defaults.mode = 'rfc3986-non-unicode'

/**
 * Slugify 文本
 * @param textToSlugify 待 slugify 的文本
github weeco / wrap-royale / src / utils / LocationHelper.ts View on Github external
regionCode?: string;
  slug: string;
}

/**
 * Helper class for retrieving locations by id or name
 */
export namespace LocationHelper {
  const locationById: Map = new Map();
  const locationBySlug: Map = new Map();
  const slugOptions: {} = {
    replacement: '-', // replace spaces with replacement
    symbols: true, // replace unicode symbols or not
    remove: /[.]/g, // (optional) regex to remove characters
    lower: true, // result in lower case
    charmap: slug.charmap, // replace special characters
    multicharmap: slug.multicharmap // replace multi-characters
  };

  // Add icon urls for all locations
  const cdnUrl: string = 'https://raw.githubusercontent.com/weeco/clash-royale-assets/master/images';
  // Load location object array into Map
  countriesJson.forEach((location: IApiLocation) => {
    const locationDetailed: ILocationDetails = {
      ...location,
      iconUrls: {
        large: `${cdnUrl}/clash-royale/locations/${location.countryCode}.png`
      },
      slug: slug(location.name, slugOptions)
    };

    locationById.set(location.id, locationDetailed);
github 3scale / 3scale-cli / lib / swagger.js View on Github external
var cli = require("./3scale-cli");
var config = require("./config");
var parrser = require("swagger-parser");
var SwaggerParser = require('swagger-parser');
var Q = require("q");
Q.longStackSupport = true;
const delayed = require('delay-promise');
var inquirer = require("inquirer");

var slug = require("slug");
slug.charmap['{'] = '_'
slug.charmap['}'] = '_'
slug.charmap['\/'] = '_SLASH_'

var services = require("./services");
var appplan = require("./application_plans");
var metrics = require("./metrics");
var methods = require("./methods");
var maprules = require("./mappingrules");

var HIT_METRIC_ID ="";
var METHODS = []

var ALLOWED_METHODS = [
  "GET","POST","PUT","OPTIONS","PATCH","HEAD","DELETE"
]
github 3scale / 3scale-cli / lib / raml.js View on Github external
var parser = require("raml-1-parser");
var cli = require("./3scale-cli");
var config = require("./config");
var Q = require("q");
var slug = require("slug");
var _ = require("underscore");

var slug = require("slug");
slug.charmap['{'] = '_'
slug.charmap['}'] = '_'
slug.charmap['\/'] = '_SLASH_'

var services = require("./services");
var appplan = require("./application_plans");
var metrics = require("./metrics");
var methods = require("./methods");

var METHOD_ARR=[]
var RESOURCESTYPES={}
var api

exports.import = function(path, service_id, appplan_name,method_pattern){
  api = parser.loadApiSync(path);
  var title = api.title()+Math.floor((Math.random() * 50) + 10);

  cli.print({message: "Loading "+title+ " raml definition."});
github pszuster / 3ScaleTD / 3scale-Swagger-Import / lib / raml.js View on Github external
var parser = require("raml-1-parser");
var cli = require("./3scale-cli");
var config = require("./config");
var Q = require("q");
var slug = require("slug");
var _ = require("underscore");

var slug = require("slug");
slug.charmap['{'] = '_'
slug.charmap['}'] = '_'
slug.charmap['\/'] = '_SLASH_'

var services = require("./services");
var appplan = require("./application_plans");
var metrics = require("./metrics");
var methods = require("./methods");

var METHOD_ARR=[]
var RESOURCESTYPES={}
var api

exports.import = function(path, service_id, appplan_name,method_pattern){
  api = parser.loadApiSync(path);
  var title = api.title()+Math.floor((Math.random() * 50) + 10);
github pszuster / 3ScaleTD / 3scale-Swagger-Import / lib / raml.js View on Github external
var parser = require("raml-1-parser");
var cli = require("./3scale-cli");
var config = require("./config");
var Q = require("q");
var slug = require("slug");
var _ = require("underscore");

var slug = require("slug");
slug.charmap['{'] = '_'
slug.charmap['}'] = '_'
slug.charmap['\/'] = '_SLASH_'

var services = require("./services");
var appplan = require("./application_plans");
var metrics = require("./metrics");
var methods = require("./methods");

var METHOD_ARR=[]
var RESOURCESTYPES={}
var api

exports.import = function(path, service_id, appplan_name,method_pattern){
  api = parser.loadApiSync(path);
  var title = api.title()+Math.floor((Math.random() * 50) + 10);

  cli.print({message: "Loading "+title+ " raml definition."});
github feross / studynotes.org / model / plugin.js View on Github external
var config = require('../config')
var mongoose = require('mongoose')
var slug = require('slug')
var util = require('../util')
var validate = require('mongoose-validator')

slug.defaults.mode = 'studynotes'
slug.defaults.modes.studynotes = {
  replacement: '-',
  symbols: true,
  remove: /[.]/g,
  lower: true,
  charmap: slug.charmap,
  multicharmap: slug.multicharmap
}

/**
 * Mongoose plugins
 */

exports.modifyDate = function (schema, opts) {
  schema.add({ modifyDate: Date })

  schema.pre('save', function (next) {
    this.modifyDate = new Date()
    next()
  })

  if (opts && opts.index) {
github pszuster / 3ScaleTD / 3scale-Swagger-Import / lib / raml.js View on Github external
var parser = require("raml-1-parser");
var cli = require("./3scale-cli");
var config = require("./config");
var Q = require("q");
var slug = require("slug");
var _ = require("underscore");

var slug = require("slug");
slug.charmap['{'] = '_'
slug.charmap['}'] = '_'
slug.charmap['\/'] = '_SLASH_'

var services = require("./services");
var appplan = require("./application_plans");
var metrics = require("./metrics");
var methods = require("./methods");

var METHOD_ARR=[]
var RESOURCESTYPES={}
var api

exports.import = function(path, service_id, appplan_name,method_pattern){
  api = parser.loadApiSync(path);
  var title = api.title()+Math.floor((Math.random() * 50) + 10);

  cli.print({message: "Loading "+title+ " raml definition."});
github stephanediondev / elasticsearch-admin / assets / js / app.js View on Github external
require('jquery');
global.$ = global.jQuery = $;

require('bootstrap');

require('select2');

import { saveAs } from 'file-saver';
var slug = require('slug');
slug.charmap['/'] = '-';
slug.charmap['?'] = '-';
slug.charmap['='] = '-';
global.slug = slug;

global.sleep = function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

global.createToast = function createToast(body) {
    var toast = `<div aria-atomic="true" aria-live="assertive" role="alert" class="toast bg-dark text-light border border-secondary">
        <div class="toast-body">
            ${body}
        </div>
    </div>`;
    $('#toast-container').prepend(toast);
    var toastObject = $('#toast-container .toast').first();
github stephanediondev / elasticsearch-admin / assets / js / app.js View on Github external
require('jquery');
global.$ = global.jQuery = $;

require('bootstrap');

require('select2');

import { saveAs } from 'file-saver';
var slug = require('slug');
slug.charmap['/'] = '-';
slug.charmap['?'] = '-';
slug.charmap['='] = '-';
global.slug = slug;

global.sleep = function sleep(ms) {
    return new Promise(resolve =&gt; setTimeout(resolve, ms));
}

global.createToast = function createToast(body) {
    var toast = `<div aria-atomic="true" aria-live="assertive" role="alert" class="toast bg-dark text-light border border-secondary">
        <div class="toast-body">
            ${body}
        </div>
    </div>`;
    $('#toast-container').prepend(toast);
    var toastObject = $('#toast-container .toast').first();
    toastObject.toast({'autohide': true, 'delay': 5000});

slug

slugifies even utf-8 chars!

MIT
Latest version published 18 days ago

Package Health Score

86 / 100
Full package analysis