File tree 2 files changed +44
-44
lines changed
2 files changed +44
-44
lines changed Original file line number Diff line number Diff line change @@ -30,45 +30,45 @@ module.exports = {
30
30
//
31
31
// Requests to the cdnDomain will bypass this whitelist and proxy all file
32
32
// types. Please keep this list alphabetized.
33
- extensionWhitelist : {
34
- '.appcache' : true ,
35
- '.coffee' : true ,
36
- '.css' : true ,
37
- '.csv' : true ,
38
- '.eot' : true ,
39
- '.geojson' : true ,
40
- '.handlebars' : true ,
41
- '.hbs' : true ,
42
- '.htm' : true ,
43
- '.html' : true ,
44
- '.js' : true ,
45
- '.json' : true ,
46
- '.jsonld' : true ,
47
- '.kml' : true ,
48
- '.md' : true ,
49
- '.n3' : true ,
50
- '.nt' : true ,
51
- '.otf' : true ,
52
- '.owl' : true ,
53
- '.pdf' : true ,
54
- '.rdf' : true ,
55
- '.rss' : true ,
56
- '.svg' : true ,
57
- '.swf' : true ,
58
- '.ttc' : true ,
59
- '.ttf' : true ,
60
- '.ttl' : true ,
61
- '.vtt' : true ,
62
- '.woff' : true ,
63
- '.woff2' : true ,
64
- '.xht' : true ,
65
- '.xhtml' : true ,
66
- '.xml' : true ,
67
- '.xsl' : true ,
68
- '.xslt' : true ,
69
- '.yaml' : true ,
70
- '.yml' : true
71
- } ,
33
+ extensionWhitelist : new Set ( [
34
+ '.appcache' ,
35
+ '.coffee' ,
36
+ '.css' ,
37
+ '.csv' ,
38
+ '.eot' ,
39
+ '.geojson' ,
40
+ '.handlebars' ,
41
+ '.hbs' ,
42
+ '.htm' ,
43
+ '.html' ,
44
+ '.js' ,
45
+ '.json' ,
46
+ '.jsonld' ,
47
+ '.kml' ,
48
+ '.md' ,
49
+ '.n3' ,
50
+ '.nt' ,
51
+ '.otf' ,
52
+ '.owl' ,
53
+ '.pdf' ,
54
+ '.rdf' ,
55
+ '.rss' ,
56
+ '.svg' ,
57
+ '.swf' ,
58
+ '.ttc' ,
59
+ '.ttf' ,
60
+ '.ttl' ,
61
+ '.vtt' ,
62
+ '.woff' ,
63
+ '.woff2' ,
64
+ '.xht' ,
65
+ '.xhtml' ,
66
+ '.xml' ,
67
+ '.xsl' ,
68
+ '.xslt' ,
69
+ '.yaml' ,
70
+ '.yml' ,
71
+ ] ) ,
72
72
73
73
// Whether we're running in a production environment (true) or
74
74
// development/test (false).
Original file line number Diff line number Diff line change 3
3
const config = require ( '../../conf' ) ;
4
4
const path = require ( 'path' ) ;
5
5
6
+ const { extensionWhitelist } = config ;
7
+
6
8
// Redirects requests for non-whitelisted file extensions directly to GitHub,
7
9
// since there's no value in proxying them.
8
10
module . exports = rootUrl => {
9
11
return ( req , res , next ) => {
10
- if ( req . isCDN ) {
12
+ if ( req . isCDN || req . path . endsWith ( '/' ) ) {
11
13
return void next ( ) ;
12
14
}
13
15
14
- if ( config . extensionWhitelist [ path . extname ( req . path ) . toLowerCase ( ) ] ) {
15
- return void next ( ) ;
16
- }
16
+ let extension = path . extname ( req . path ) . toLowerCase ( ) ;
17
17
18
- if ( / \/ $ / . test ( req . path ) ) {
18
+ if ( extensionWhitelist . has ( extension ) ) {
19
19
return void next ( ) ;
20
20
}
21
21
You can’t perform that action at this time.
0 commit comments