This repository was archived by the owner on Apr 19, 2018. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathweb.js
More file actions
47 lines (42 loc) · 1.99 KB
/
Copy pathweb.js
File metadata and controls
47 lines (42 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var app = require('express').createServer();
//Simple static URL redirection
var simples = {
'/github' : 'https://github.com/JakeWharton/ActionBarSherlock',
'/issues' : 'https://github.com/JakeWharton/ActionBarSherlock/issues',
'/download' : 'http://actionbarsherlock.com/download.html',
'/group' : 'https://groups.google.com/group/actionbarsherlock',
'/forum' : 'https://groups.google.com/group/actionbarsherlock',
'/store' : 'http://actionbarsherlock.spreadshirt.com',
'/shop' : 'http://actionbarsherlock.spreadshirt.com',
'/flattr' : 'https://flattr.com/thing/320252/ActionBarSherlock',
'/ohloh' : 'https://www.ohloh.net/p/ActionBarSherlock',
'/donate' : 'http://actionbarsherlock.com/merch-and-donations.html',
'/changelog': 'https://github.com/JakeWharton/ActionBarSherlock/blob/master/CHANGELOG.md#readme',
'/tags' : 'https://github.com/JakeWharton/ActionBarSherlock/tags',
'/market' : 'https://market.android.com/search?q=com.actionbarsherlock',
'/4' : 'https://github.com/JakeWharton/ActionBarSherlock/issues?milestone=4&state=open',
}
for (var simple in simples) {
console.log('Redirecting "' + simple + '" to "' + simples[simple] + '"');
app.get(simple, function(req, res) {
res.redirect(simples[req.url]);
});
}
//Regex-based URL redirection
app.get(/^\/i(?:ssues?)?\/([0-9]+)/, function(req, res) {
res.redirect('https://github.com/JakeWharton/ActionBarSherlock/issues/' + req.params[0]);
});
app.get(/^\/b(?:ranch)?\/([.a-zA-Z0-9_-]+)/, function(req, res) {
res.redirect('https://github.com/JakeWharton/ActionBarSherlock/tree/' + req.params[0]);
});
app.get(/^\/([0-9A-Fa-f]{6,})/, function(req, res) {
res.redirect('https://github.com/JakeWharton/ActionBarSherlock/commit/' + req.params[0]);
});
//Catch-all
app.get('*', function(req, res) {
res.redirect('http://actionbarsherlock.com' + req.url);
});
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on " + port);
});