diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 00cf4cd6..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@remy/eslint')('node'); diff --git a/licenses/ISC.ejs b/licenses/ISC.ejs index 4f433020..d993b2b0 100644 --- a/licenses/ISC.ejs +++ b/licenses/ISC.ejs @@ -1,26 +1,27 @@ <%- include('components/header') %> + -
-<%- gravatar %> -

The ISC License (ISC)

+
+ <%- gravatar %> +

The ISC License (ISC)

-

Copyright © <%- info %>

+

Copyright © <%- info %>

-

Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies.

+

Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies.

-

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

-
-<%- include('components/footer') %> +

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

+
+ <%- include('components/footer') %> diff --git a/licenses/MIT.ejs b/licenses/MIT.ejs index 9823d05f..a3eda69a 100644 --- a/licenses/MIT.ejs +++ b/licenses/MIT.ejs @@ -1,32 +1,33 @@ <%- include('components/header') %> + -
-<%- gravatar %> -

The MIT License (MIT)

+
+ <%- gravatar %> +

The MIT License (MIT)

-

Copyright © <%- info %>

+

Copyright © <%- info %>

-

Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions:

+

Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the “Software”), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions:

-

The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software.

+

The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software.

-

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.

-
-<%- include('components/footer') %> +

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE.

+
+ <%- include('components/footer') %> diff --git a/licenses/components/footer.ejs b/licenses/components/footer.ejs index 4f857c83..2efbcf12 100644 --- a/licenses/components/footer.ejs +++ b/licenses/components/footer.ejs @@ -1,3 +1,4 @@ diff --git a/licenses/components/header.ejs b/licenses/components/header.ejs index 3ad2e4ab..92f315b9 100644 --- a/licenses/components/header.ejs +++ b/licenses/components/header.ejs @@ -1,38 +1,37 @@ -MIT License - - - - - - - - + + diff --git a/package.json b/package.json index 101c86ca..689154ca 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,4 @@ { - "author": "Remy Sharp (http://remysharp.com/)", "name": "mit-licence", "description": "Hosted MIT License with details controlled through this repo", "private": true, @@ -12,12 +11,7 @@ "engines": { "node": ">=10" }, - "husky": { - "hooks": { - "pre-commit": "npm run lint", - "pre-push": "npm test" - } - }, + "author": "Remy Sharp (http://remysharp.com/)", "scripts": { "start": "node .", "dev": "nodemon .", @@ -30,28 +24,38 @@ }, "license": "MIT", "dependencies": { - "@octokit/rest": "^16.36.0", + "@octokit/rest": "^16.41.0", + "@sindresorhus/is": "^2.0.0", + "any-size": "^1.0.0", "btoa": "^1.2.1", "ejs": "^3.0.1", + "escape-html": "^1.0.3", "express": "^4.17.1", "express-minify": "^1.0.0", "fs-extra": "^8.1.0", - "lodash": "^4.17.15", + "html-text": "^1.0.1", "md5": "^2.2.1", "postcss-middleware": "^1.1.4", "postcss-preset-env": "^6.7.0", "serve-favicon": "^2.5.0", "temp-dir": "^2.0.0", + "unescape-html": "^1.1.0", "yn": "^4.0.0" }, "devDependencies": { "css": "^2.2.4", "has-flag": "^4.0.0", - "husky": "^4.0.7", + "husky": "^4.2.1", "nodemon": "^2.0.2", "standard": "^14.3.1" }, "resolutions": { "postcss-middleware/vinyl-fs/glob-stream/micromatch/braces": "^3.0.2" + }, + "husky": { + "hooks": { + "pre-commit": "npm run lint", + "pre-push": "npm test" + } } } diff --git a/routes/get.js b/routes/get.js index 15d0f937..7193ceb8 100644 --- a/routes/get.js +++ b/routes/get.js @@ -1,12 +1,14 @@ const md5 = require('md5') const path = require('path') -const { stripTags, escapeTags, unescapeTags } = require('./utils') -const _ = require('lodash') +const escapeTags = require('escape-html') +const unescapeTags = require('unescape-html') +const stripTags = require('html-text') +const is = require('@sindresorhus/is') function getCopyrightHTML (user, plain) { let html = '' - const name = _.isString(user) + const name = is.string(user) ? user : plain ? user.name || user.copyright @@ -34,9 +36,9 @@ module.exports = (req, res) => { // No error and valid if (user.copyright) { - if (_.isString(user.copyright)) { + if (is.string(user.copyright)) { name = getCopyrightHTML(user, options.format !== 'html') - } else if (_.isArray(user.copyright) && user.copyright.every(val => _.isString(val))) { + } else if (is.array(user.copyright) && user.copyright.every(val => is.string(val))) { // Supports: ['Remy Sharp', 'Richie Bendall'] name = user.copyright .map(v => (options.format !== 'html' ? v : escapeTags(v))) @@ -51,7 +53,7 @@ module.exports = (req, res) => { gravatar = `Profile image` - } else if (_.isObject(user.copyright[0]) && user.gravatar) { + } else if (is.object(user.copyright[0]) && user.gravatar) { // Supports multi-user format gravatar = `Profile image { } // Extract the name from the URL - const id = _.first(params) + const id = params[0] if (!validDomainId(id)) { // Return a vague error intentionally @@ -65,7 +66,7 @@ module.exports = async (req, res) => { if (userData.gravatar) { // Parse the string version of a boolean or similar userData.gravatar = yn(userData.gravatar, { lenient: true }) - if (_.isUndefined(userData.gravatar)) { + if (is.undefined(userData.gravatar)) { res .status(400) .send( diff --git a/routes/utils.js b/routes/utils.js index 869c28af..d07c3d94 100644 --- a/routes/utils.js +++ b/routes/utils.js @@ -1,16 +1,3 @@ -const _ = require('lodash') - -const tags = { - '<': '<', - '>': '>', - '&': '&' -} -const untags = _.invert(tags) - module.exports = { - escapeTags: str => (str || '').replace(/[<>&]/g, m => tags[m]), - unescapeTags: str => - (str || '').replace(/(<|>|&)/g, m => untags[m]), - stripTags: str => (str || '').replace(/<(?:.|\n)*?>/gm, ''), validDomainId: str => /^[\w-_]+$/.test(str) } diff --git a/server.js b/server.js index 6df2a972..8dbac25d 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,7 @@ const express = require('express') const minify = require('express-minify') const favicon = require('serve-favicon') const postcssMiddleware = require('postcss-middleware') -const tmpdir = require('temp-dir') +const tempdir = require('temp-dir') const path = require('path') // Server @@ -19,7 +19,7 @@ var PORT = process.env.PORT || 8080 const app = express() app.use( minify({ - cache: tmpdir + cache: tempdir }) ) app.use(favicon(path.join(__dirname, 'favicon.ico'))) diff --git a/yarn.lock b/yarn.lock index 46bd5c3c..9774c241 100644 Binary files a/yarn.lock and b/yarn.lock differ