Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-url-slugs

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-url-slugs - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

12

index.js

@@ -43,6 +43,8 @@ var extend = require('extend');

if (!options.index_unique) return cb(null, true, slug);
var doc = this;
var model = doc.constructor;
var q = {};
q[options.field] = new RegExp('^' + slug);
var doc = this,
model = doc.constructor,
slugLimited = (options.maxLength && slug.length == options.maxLength)? true : false,
q = {};
q[options.field] = new RegExp('^' + (slugLimited? slug.substr(0, slug.length - 2) : slug));
q._id = {$ne: doc._id};

@@ -59,3 +61,3 @@ var fields = {};

if (docSlug != slug) {
count = docSlug.match(new RegExp(slug + options.separator + '([0-9]+)$'));
count = docSlug.match(new RegExp((slugLimited? slug.substr(0, slug.length - 2) : slug) + options.separator + '([0-9]+)$'));
count = ((count instanceof Array)? parseInt(count[1], 10) : 0) + 1;

@@ -62,0 +64,0 @@ }

@@ -9,3 +9,3 @@ {

"description": "Create URL compatiable slugs on mongoose models, ensuring uniqueness.",
"version": "0.1.0",
"version": "0.1.1",
"keywords": [

@@ -12,0 +12,0 @@ "mongoose slugs",

@@ -56,5 +56,5 @@ [![Build Status](https://travis-ci.org/mindblaze/mongoose-url-slugs.png?branch=master)](https://travis-ci.org/mindblaze/mongoose-url-slugs)

## Defaults and Configurables
## Default options
* **field** (Default: 'slug') - field to use for slug building/
* **field** (Default: 'slug') - Slug field to use for storage.
* **addField** (Default: True) - Add slug field to mongoose schema.

@@ -75,2 +75,3 @@ * **separator** (Default: '-') - Separator to use for invalid characters.

## History
* v0.1.1 (2014-12-09) -- Fixed an issue due to maxLength.
* v0.1.0 (2014-11-28) -- Added index_sparse, maxLength options.

@@ -77,0 +78,0 @@ * v0.0.10 (2014-10-14) -- Dependencies updated.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc