How to use @tryghost/string - 2 common examples

To help you get started, we’ve selected a few @tryghost/string 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 TryGhost / Ghost-Admin / app / controllers / tag.js View on Github external
// avoid modifying empty values and triggering inadvertant unsaved changes modals
        if (newValue !== false && !newValue && !currentValue) {
            return;
        }

        // Quit if there was no change
        if (newValue === currentValue) {
            return;
        }

        tag.set(propKey, newValue);

        // Generate slug based on name for new tag when empty
        if (propKey === 'name' && !tag.slug && tag.isNew) {
            let slugValue = slugify(newValue);
            if (/^#/.test(newValue)) {
                slugValue = 'hash-' + slugValue;
            }
            tag.set('slug', slugValue);
        }

        // TODO: This is required until .validate/.save mark fields as validated
        tag.get('hasValidated').addObject(propKey);
    }
});
github chadly / ghost / core / server / lib / security / string.js View on Github external
module.exports.safe = function safe(string, options) {
    options = options || {};
    let opts = {requiredChangesOnly: true};
    if (!_.has(options, 'importing') || !options.importing) {
        opts.requiredChangesOnly = false;
    }
    return slugify(string, opts);
};

@tryghost/string

## Install

MIT
Latest version published 15 days ago

Package Health Score

69 / 100
Full package analysis

Popular @tryghost/string functions

Similar packages