Skip to content

Commit

Permalink
🐛 Path fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samdenty committed Jan 11, 2018
1 parent e0368d8 commit b15d7d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ MongoClient.connect(config.mongodb, function (err, client) {
app.use('/projects/*', function (req, res) {
if (req.originalUrl.includes('/vs/')) {
var vs = req.originalUrl.split('/vs/');
vs = 'interface/vs/' + path.normalize(vs[vs.length - 1]);
vs = '../interface/vs/' + path.normalize(vs[vs.length - 1]);
if (fs.existsSync(vs)) {
res.sendFile(path.join(__dirname, vs));
}
Expand All @@ -1710,11 +1710,11 @@ MongoClient.connect(config.mongodb, function (err, client) {
}
}
else {
res.sendFile(path.join(__dirname, 'interface/index.html'));
res.sendFile(path.join(__dirname, '../interface/index.html'));
}
});
app.use('/config', function (req, res) {
res.sendFile(path.join(__dirname, 'interface/index.html'));
res.sendFile(path.join(__dirname, '../interface/index.html'));
});
app.use(express.static(path.join(__dirname, 'interface')));
}
Expand Down
8 changes: 3 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ MongoClient.connect(config.mongodb, (err, client) => {
let Inject = new injectHandler(server, db)
let inject = global.inject = Inject.state



io.on('connection', socket => {
let globalToken
let state = {
Expand Down Expand Up @@ -1672,18 +1670,18 @@ MongoClient.connect(config.mongodb, (err, client) => {
app.use('/projects/*', (req, res) => {
if (req.originalUrl.includes('/vs/')) {
let vs = req.originalUrl.split('/vs/')
vs = 'interface/vs/' + path.normalize(vs[vs.length - 1])
vs = '../interface/vs/' + path.normalize(vs[vs.length - 1])
if (fs.existsSync(vs)) {
res.sendFile(path.join(__dirname, vs))
} else {
res.status(404).send('Not found')
}
} else {
res.sendFile(path.join(__dirname, 'interface/index.html'))
res.sendFile(path.join(__dirname, '../interface/index.html'))
}
})
app.use('/config', (req, res) => {
res.sendFile(path.join(__dirname, 'interface/index.html'))
res.sendFile(path.join(__dirname, '../interface/index.html'))
})
app.use(express.static(path.join(__dirname, 'interface')))
}
Expand Down

0 comments on commit b15d7d6

Please sign in to comment.