Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
fix trailing slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
bigansh committed Aug 12, 2021
1 parent 2b714b0 commit 295ff70
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const express = require('express'),
app.set('view engine', 'ejs')

app.use(express.urlencoded({ extended: true }))
app.use(express.static('public'))
app.use(express.static('public', { redirect: false }))
app.use(expressSanitizer())
app.use(methodOverride('_method'))

Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author": "bigansh",
"license": "ISC",
"dependencies": {
"connect-slashes": "^1.4.0",
"dotenv": "^9.0.1",
"ejs": "^3.1.6",
"express": "^4.17.1",
Expand Down
7 changes: 4 additions & 3 deletions router/blogs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const express = require('express'),
router = express.Router()
router = express.Router(),
slashes = require('connect-slashes')

const Blog = require('../models/blogSchema')

router.get('/', (req, res) => {
router.get('/', slashes(), (req, res) => {
res.render('blogs')
})

Expand All @@ -19,7 +20,7 @@ router.post('/', (req, res) => {
})
})

router.get('/:category', (req, res) => {
router.get('/:category', slashes(), (req, res) => {
if (req.params.category === 'science') {
Blog.find({ tag: 'Science' })
.sort([['created', -1]])
Expand Down

0 comments on commit 295ff70

Please sign in to comment.