@@ -3,7 +3,8 @@ var fs = Promise.promisifyAll(require('fs-extra'));
33var path = require ( 'path' ) ;
44var _ = require ( 'underscore' ) ;
55
6- var defaults = require ( './config/defaults.js' ) ;
6+ var defaults = require ( './config/defaults' ) ;
7+ var types = require ( './config/resource-types' ) ;
78var utils = require ( './utils.js' ) ;
89var request = require ( './request' ) ;
910var Resource = require ( './resource' ) ;
@@ -37,8 +38,8 @@ function generateFilename (resource) {
3738 var occupiedFilenames = self . getOccupiedFilenames ( ) ;
3839
3940 var preferedFilename = resource . getFilename ( ) ; // which was set in options
40- var urlFilename = path . basename ( resource . getUrl ( ) ) ; // try to get filename from url
41- var filename = utils . trimFilename ( preferedFilename || urlFilename ) ;
41+ var urlFilename = utils . getFilenameFromUrl ( resource . getUrl ( ) ) ; // try to get filename from url
42+ var filename = preferedFilename || urlFilename || self . options . defaultFilename ;
4243
4344 var ext = path . extname ( filename ) ;
4445 var dir = self . getDirectoryByExtension ( ext ) ;
@@ -64,8 +65,8 @@ function getDirectoryByExtension (ext) {
6465function getHandleFunction ( resource ) {
6566 var type = resource . getType ( ) ;
6667 switch ( type ) {
67- case ' css' : return loadCss ;
68- case ' html' : return function loadHtmlAndCss ( context , po ) {
68+ case types . css : return loadCss ;
69+ case types . html : return function loadHtmlAndCss ( context , po ) {
6970 return loadHtml ( context , po ) . then ( function ( loaded ) {
7071 return loadCss ( context , loaded ) ;
7172 } ) ;
0 commit comments