How to use the slug.defaults 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 GetPublii / Publii / app / back-end / helpers / slug.js View on Github external
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';

function createSlug(textToSlugify, filenameMode = false, saveLowerChars = false) {
    textToSlugify = transliterate(textToSlugify);

    if(!filenameMode) {
        if(saveLowerChars) {
            slug.defaults.mode = 'rfc3986-non-unicode-with-dots-no-lower';
        }
github crablar / podsheets / server / src / lib / googleCloudStorage.ts View on Github external
req.on("response", res => {
            // Don't set up the pipe to the write stream unless the status is ok.
            if (res.statusCode !== 200) {
                return;
            }
            slug.defaults.mode = "rfc3986";
            const secureFilename = `${new Date().getTime()}/${slug(objectName)}`;
            // tslint:disable-next-line:no-console
            const writeStream = bucket.file(secureFilename)
                .createWriteStream({

                    // Tweak the config options as desired.
                    gzip: false,
                    public: true,
                    resumable: true,
                    metadata: {
                        contentType: res.headers["content-type"],
                    },
                });
            req.pipe(writeStream)
                .on("finish", () => {
                    const bucketName = config.google.storage.bucket;
github bipbop / harlan / src / plugins / lib / icheques / ban-factory.js View on Github external
import jDataView from 'jdataview';
import { sprintf } from 'sprintf';
import { CMC7Parser } from './cmc7-parser';
import async from 'async';
import { CPF } from 'cpf_cnpj';
import { CNPJ } from 'cpf_cnpj';
import slug from 'slug';

slug.defaults.modes.pretty = {
    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 ='pretty';

const NON_NUMERIC = /[\D]/g;
const NON_WORD = /[\W]/g;
const ROW_SIZE = 502;
const BAN_VERSION = '02.7';
const MAX_THREADS = 2;
const CRLF = '\r\n';
github outline / outline / server / models / Document.js View on Github external
import Sequelize, { type Transaction } from 'sequelize';
import removeMarkdown from '@tommoor/remove-markdown';

import isUUID from 'validator/lib/isUUID';
import { Collection, User } from '../models';
import { DataTypes, sequelize } from '../sequelize';
import parseTitle from '../../shared/utils/parseTitle';
import unescape from '../../shared/utils/unescape';
import Revision from './Revision';

const Op = Sequelize.Op;
const Markdown = new MarkdownSerializer();
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
const DEFAULT_TITLE = 'Untitled';

slug.defaults.mode = 'rfc3986';
const slugify = text =>
  slug(text, {
    remove: /[.]/g,
  });

const createRevision = (doc, options = {}) => {
  // we don't create revisions for autosaves
  if (options.autosave) return;

  // we don't create revisions if identical to previous
  if (doc.text === doc.previous('text')) return;

  return Revision.create(
    {
      title: doc.title,
      text: doc.text,
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 })
github crablar / podsheets / server / src / routes / main.ts View on Github external
router.get("/upload_policy", auth.mustBeLoggedIn, async (req, res) => {
        try {
            if (req.query && req.query.filename && req.query.type) {
                slug.defaults.mode = "rfc3986";
                const secureFilename = `${new Date().getTime()}/${slug(req.query.filename)}`;
                const uploadUrl = await getSignedUrlForUpload(secureFilename, req.query.type);
                const bucket = config.google.storage.bucket;
                const publicFileUrl = `http://storage.googleapis.com/${bucket}/${secureFilename}`;
                res.json({ uploadUrl, publicFileUrl });
            } else {
                throw new Error("No filename provided.");
            }
        } catch (err) {
            logger.error("UploadPolicy Error: ", err);
            res.sendStatus(403);
        }
    });
github service-bot / servicebot / views / components / pages / embeddables.jsx View on Github external
import React from 'react';
import consume from "pluginbot-react/dist/consume";
import slug from "slug";

slug.defaults.mode = "rfc3986";
let EmbeddableCard = function(props){
    let {name, description, iconUrl, component, selected} = props;
    return(
        <div>
            <img src="{iconUrl}/" alt="{`Get">
            <span>{name}</span>
            {/*<span>{description}</span>*/}
        </div>
    );
}

class Embeddables extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            selected : (props.params &amp;&amp; props.params.embedName) || "default"
github thekelvinliu / generator-espress / src / app / index.js View on Github external
constructor(...args) {
    super(...args);
    slug.defaults.mode = 'rfc3986';
    this.opts = {
      year: new Date().getFullYear()
    };
  }
github GetPublii / Publii / app / back-end / helpers / slug.js View on Github external
function createSlug(textToSlugify, filenameMode = false, saveLowerChars = false) {
    textToSlugify = transliterate(textToSlugify);

    if(!filenameMode) {
        if(saveLowerChars) {
            slug.defaults.mode = 'rfc3986-non-unicode-with-dots-no-lower';
        }

        textToSlugify = slug(textToSlugify);
        slug.defaults.mode = 'rfc3986-non-unicode';
    } else {
        slug.defaults.mode = 'rfc3986-non-unicode-with-dots';
        textToSlugify = slug(textToSlugify);
        slug.defaults.mode = 'rfc3986-non-unicode';
    }

    return textToSlugify;
}
github davidosomething / 16.davidosomething.com / lib / metalsmith-set-file-defaults / index.js View on Github external
const siteData      = require('../site.js');
const util          = require('util');
const debug         = require('debug');
const defaultsDeep  = require('lodash.defaultsdeep');
const slug          = require('slug');

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


/**
 * Default widgets for each file type
 * @constant
 * @type {Object}
 */
const DEFAULT_WIDGETS = {
  page: {
    aboutMe:  true,
    allPosts: true,
  },
  post: {
    sharePost: true,
    aboutMe:   true,
    allPosts:  true,

slug

slugifies even utf-8 chars!

MIT
Latest version published 1 month ago

Package Health Score

83 / 100
Full package analysis