@@ -21,7 +21,8 @@ var CONFIGURATION = {
2121 mode : VCR_MODE ,
2222 fixturePath : './_fixtures' ,
2323 headerBlacklist : [ 'authorization' , 'user-agent' ] , // These need to be lowercase
24- ignoreUrls : [ ] // regex of urls to ignore
24+ ignoreUrls : [ ] , // regex of urls to ignore
25+ fixtureName : '[url]_[method]_[hash]'
2526}
2627
2728function debug ( url , message ) {
@@ -91,13 +92,19 @@ function buildHash(url, args) {
9192}
9293
9394function buildFilenamePrefix ( url , args , hash ) {
94- args = args || { }
9595 var [ baseUrl , query ] = url . split ( '?' )
9696 url = escape ( baseUrl ) . replace ( / \/ / g, '_' )
97- var method = args . method || 'GET'
97+ url += query ? '_' + hashCode ( query ) : ''
98+
99+ var method = ( args || { } ) . method || 'GET'
98100 method = method . toUpperCase ( )
99- var paramsHash = query ? '_' + hashCode ( query ) : ''
100- return url + paramsHash + '_' + method + '_' + hash
101+
102+ var fixtureName = CONFIGURATION . fixtureName
103+
104+ return fixtureName
105+ . replace ( / \[ u r l \] / g, url )
106+ . replace ( / \[ m e t h o d \] / g, method )
107+ . replace ( / \[ h a s h \] / g, hash )
101108}
102109
103110function buildOptionsFilename ( url , args , hash ) {
@@ -244,6 +251,7 @@ fetchVCR.configure = function (config) {
244251 CONFIGURATION . mode = VCR_MODE || config . mode
245252 CONFIGURATION . fixturePath = config . fixturePath || CONFIGURATION . fixturePath
246253 CONFIGURATION . ignoreUrls = config . ignoreUrls || CONFIGURATION . ignoreUrls
254+ CONFIGURATION . fixtureName = config . fixtureName || CONFIGURATION . fixtureName
247255 if ( config . headerBlacklist ) {
248256 CONFIGURATION . headerBlacklist = [ ]
249257 config . headerBlacklist . forEach ( function ( key ) {
0 commit comments