git ssb

9+

cel / ssb-viewer



Commit 36c63bc1828456bf3417ff9eb5187cfcb776b3b2

Consolidate serve functions

cel committed on 8/22/2018, 7:58:51 PM
Parent: c8c744f585c7b47c5bc661ec8df7d5caf8d21ed8

Files changed

index.jschanged
index.jsView
@@ -80,8 +80,11 @@
8080 }
8181
8282 var m = urlIdRegex.exec(req.url)
8383
84 + if (m[4] === '/robots.txt') return serveRobots(req, res, conf)
85 + if (req.url.startsWith('/static/')) return serveStatic(req, res, m[4])
86 + if (req.url.startsWith('/emoji/')) return serveEmoji(req, res, m[4])
8487 if (req.url.startsWith('/user-feed/')) return serveUserFeed(req, res, m[4])
8588 else if (req.url.startsWith('/channel/')) return serveChannel(req, res, m[4])
8689 else if (req.url.startsWith('/.well-known/acme-challenge')) return serveAcmeChallenge(req, res)
8790 else if (req.url.startsWith('/web/')) return serveWeb(req, res, m[4])
@@ -93,10 +96,10 @@
9396 switch (m[2]) {
9497 case '%': return serveId(req, res, m[1], m[3], m[5])
9598 case '@': return serveFeed(req, res, m[1], m[3], m[5])
9699 case '&': return serveBlob(req, res, sbot, m[1])
97- default: return servePath(req, res, m[4], conf)
98100 }
101 + return respond(res, 404, 'Not found')
99102 }
100103
101104 function serveFeed(req, res, feedId, ext) {
102105 console.log("serving feed: " + feedId)
@@ -495,20 +498,8 @@
495498 case 'rss': return 'text/xml'
496499 }
497500 }
498501
499-function servePath(req, res, url, conf) {
500- switch (url) {
501- case '/robots.txt': return serveRobots(req, res, conf)
502- }
503- var m = /^(\/?[^\/]*)(\/.*)?$/.exec(url)
504- switch (m[1]) {
505- case '/static': return serveStatic(req, res, m[2])
506- case '/emoji': return serveEmoji(req, res, m[2])
507- }
508- return respond(res, 404, 'Not found')
509-}
510-
511502 function ifModified(req, lastMod) {
512503 var ifModSince = req.headers['if-modified-since']
513504 if (!ifModSince) return false
514505 var d = new Date(ifModSince)

Built with git-ssb-web