diff --git a/README.md b/README.md index 55ebe60..fc57ba0 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Try it out at [paste.fyi](https://paste.fyi/) * Automatic and configurable paste expiry * Full support for CLI requests with [curl](https://curl.haxx.se/), [Wget](https://www.gnu.org/software/wget/) etc * CTRL+Enter hotkey for quick paste submission -* Short URLs via [shortid](https://github.com/dylang/shortid), e.g. `NyQO9puMe` +* Short and readable URLs via [nanoid](https://github.com/ai/nanoid), e.g. `/qNGDwRyx` * Textarea grows to fit content via [autosize.js](https://github.com/jackmoore/autosize) * Runs fully containerized with [Docker](https://www.docker.com/) @@ -20,7 +20,7 @@ Try it out at [paste.fyi](https://paste.fyi/) ```sh # Simple paste $ echo 'Hello World' | curl -F 'paste=<-' paste.fyi -http://paste.fyi/N15FNVqfg +http://paste.fyi/qNGDwRyx # Either form, multipart or raw text data is accepted $ curl -F 'paste=Sent as form data' https://paste.fyi diff --git a/models/paste.js b/models/paste.js index bf77c26..fabdd49 100644 --- a/models/paste.js +++ b/models/paste.js @@ -1,8 +1,10 @@ const mongoose = require('mongoose'); -const shortid = require('shortid'); +const { customAlphabet } = require('nanoid'); +const dictionary = require('nanoid-dictionary'); +const nanoid = customAlphabet(dictionary.nolookalikes, 8); const paste = new mongoose.Schema({ - _id: { type: String, default: shortid.generate }, + _id: { type: String, default: nanoid }, paste: { type: String }, expiresAt: { type: Date, expires: 0 } }, { diff --git a/package-lock.json b/package-lock.json index 6b9a75f..177ea71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1880,9 +1880,9 @@ } }, "mongoose": { - "version": "5.9.25", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.9.25.tgz", - "integrity": "sha512-vz/DqJ3mrHqEIlfRbKmDZ9TzQ1a0hCtSQpjHScIxr4rEtLs0tjsXDeEWcJ/vEEc3oLfP6vRx9V+uYSprXDUvFQ==", + "version": "5.9.26", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.9.26.tgz", + "integrity": "sha512-mVddZM1mB8xg9oJQZAXaN762B01puV+jL5mPqg1HBXpEs7TG6ZZ/hEk98YRJMJff/YhIzuK3a3oos6XWtTaVUQ==", "requires": { "bson": "^1.1.4", "kareem": "2.3.1", @@ -1954,9 +1954,14 @@ } }, "nanoid": { - "version": "2.1.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz", - "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==" + "version": "3.1.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.11.tgz", + "integrity": "sha512-HyrIRpCB2uS1/sEoS7/UIAM/Jn72uXf2/yWgQRP0e16/UdMsfH/1JyLj2SqyQlkMkeeN1ad61tpT6FPRRimxnA==" + }, + "nanoid-dictionary": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/nanoid-dictionary/-/nanoid-dictionary-3.0.0.tgz", + "integrity": "sha512-dYCOXltfavrN7LGYt3DEAGl6Ya3UcnypXPsYR7HZ5k1eIesakVm+zlfv7V75uSe+Zhyxvyhg9yEbPl8qMx1dwA==" }, "natural-compare": { "version": "1.4.0", @@ -2687,14 +2692,6 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "shortid": { - "version": "2.2.15", - "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.15.tgz", - "integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==", - "requires": { - "nanoid": "^2.1.0" - } - }, "sift": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", diff --git a/package.json b/package.json index c57200f..0a54000 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,10 @@ "koa-router": "^9.1.0", "koa-static-cache": "^5.1.3", "koa-views": "^6.3.0", - "mongoose": "^5.9.25", - "pug": "^3.0.0", - "shortid": "^2.2.15" + "mongoose": "^5.9.26", + "nanoid": "^3.1.11", + "nanoid-dictionary": "^3.0.0", + "pug": "^3.0.0" }, "devDependencies": { "eslint": "^7.5.0",