Fix special keywords search redirecting
Build docker image / docker (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Deploy Jekyll with GitHub Pages dependencies preinstalled / build (push) Has been cancelled
Deploy Jekyll with GitHub Pages dependencies preinstalled / deploy (push) Has been cancelled

Fix if you search a special keywords, search result page broken css
This commit is contained in:
Sky
2024-11-21 13:52:12 +08:00
committed by GitHub
parent 931535310b
commit ff0e968907
+12 -5
View File
@@ -88,7 +88,6 @@ module.exports = (app, utils) => {
return handleWikiPage(req, res, '/wiki/')
})
// This route handles wiki-pages starting with forward slash (issue #21))
app.get('/wiki//:page?/:sub_page?', (req, res, next) => {
const page = req.params.page
if(page) {
@@ -98,6 +97,18 @@ module.exports = (app, utils) => {
return handleWikiPage(req, res, '/wiki/')
})
// Handle the search request and redirect to the correct wiki page
app.get('/w/index.php', (req, res, next) => {
const searchQuery = req.query.search
if (searchQuery) {
// Construct the URL to redirect to the proper wiki page
const lang = req.query.lang || req.cookies.default_lang || config.default_lang
const redirectUrl = `/wiki/${encodeURIComponent(searchQuery)}?lang=${lang}`
return res.redirect(redirectUrl)
}
return next()
})
app.get('/w/:file', (req, res, next) => {
return handleWikiPage(req, res, '/w/')
})
@@ -132,10 +143,6 @@ module.exports = (app, utils) => {
return handleWikiPage(req, res, '/')
})
app.get('Open in Wikipedia', (req, res, next) => {
return res.sendFile(path.join(__dirname, 'https://wikipedia.org/wiki/Wikipedia'))
})
app.get('/about', (req, res, next) => {
return res.sendFile(path.join(__dirname, '../static/about.html'))
})