11import * as config from "./config" ;
22import * as uuid from "uuid" ;
33
4- var CspStrategy : any = { }
4+ const CspStrategy : any = { }
55
6- var defaultDirectives = {
6+ const defaultDirectives = {
77 defaultSrc : [ '\'self\'' ] ,
88 scriptSrc : [ '\'self\'' , 'vimeo.com' , 'https://gist.github.com' , 'www.slideshare.net' , 'https://query.yahooapis.com' , '\'unsafe-eval\'' ] ,
99 // ^ TODO: Remove unsafe-eval - webpack script-loader issues https://github.com/hackmdio/codimd/issues/594
@@ -16,28 +16,28 @@ var defaultDirectives = {
1616 connectSrc : [ '*' ]
1717}
1818
19- var dropboxDirectives = {
19+ const dropboxDirectives = {
2020 scriptSrc : [ 'https://www.dropbox.com' ]
2121}
2222
23- var cdnDirectives = {
23+ const cdnDirectives = {
2424 scriptSrc : [ 'https://cdnjs.cloudflare.com' , 'https://cdn.jsdelivr.net' , 'https://cdn.mathjax.org' ] ,
2525 styleSrc : [ 'https://cdnjs.cloudflare.com' , 'https://cdn.jsdelivr.net' , 'https://fonts.googleapis.com' ] ,
2626 fontSrc : [ 'https://cdnjs.cloudflare.com' , 'https://fonts.gstatic.com' ]
2727}
2828
29- var disqusDirectives = {
29+ const disqusDirectives = {
3030 scriptSrc : [ 'https://disqus.com' , 'https://*.disqus.com' , 'https://*.disquscdn.com' ] ,
3131 styleSrc : [ 'https://*.disquscdn.com' ] ,
3232 fontSrc : [ 'https://*.disquscdn.com' ]
3333}
3434
35- var googleAnalyticsDirectives = {
35+ const googleAnalyticsDirectives = {
3636 scriptSrc : [ 'https://www.google-analytics.com' ]
3737}
3838
3939CspStrategy . computeDirectives = function ( ) {
40- var directives = { }
40+ const directives = { }
4141 mergeDirectives ( directives , config . csp . directives )
4242 mergeDirectivesIf ( config . csp . addDefaults , directives , defaultDirectives )
4343 mergeDirectivesIf ( config . useCDN , directives , cdnDirectives )
@@ -53,10 +53,10 @@ CspStrategy.computeDirectives = function () {
5353}
5454
5555function mergeDirectives ( existingDirectives , newDirectives ) {
56- for ( var propertyName in newDirectives ) {
57- var newDirective = newDirectives [ propertyName ]
56+ for ( const propertyName in newDirectives ) {
57+ const newDirective = newDirectives [ propertyName ]
5858 if ( newDirective ) {
59- var existingDirective = existingDirectives [ propertyName ] || [ ]
59+ const existingDirective = existingDirectives [ propertyName ] || [ ]
6060 existingDirectives [ propertyName ] = existingDirective . concat ( newDirective )
6161 }
6262 }
@@ -86,10 +86,10 @@ function getCspNonce(req, res) {
8686function addUpgradeUnsafeRequestsOptionTo ( directives ) {
8787 if ( config . csp . upgradeInsecureRequests === 'auto' && config . useSSL ) {
8888 directives . upgradeInsecureRequests = true
89- } else { // @ts -ignore
89+ } else {
9090 if ( config . csp . upgradeInsecureRequests === true ) {
91- directives . upgradeInsecureRequests = true
92- }
91+ directives . upgradeInsecureRequests = true
92+ }
9393 }
9494}
9595
0 commit comments