File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1811,7 +1811,7 @@ File.prototype.getSignedUrl = function(config, callback) {
18111811 const signedUrl = url . format ( {
18121812 protocol : parsedHost . protocol ,
18131813 hostname : parsedHost . hostname ,
1814- pathname : self . bucket . name + '/' + name ,
1814+ pathname : config . cname ? name : self . bucket . name + '/' + name ,
18151815 query : query ,
18161816 } ) ;
18171817
Original file line number Diff line number Diff line change @@ -2467,19 +2467,21 @@ describe('File', function() {
24672467 describe ( 'cname' , function ( ) {
24682468 it ( 'should use a provided cname' , function ( done ) {
24692469 const host = 'http://www.example.com' ;
2470+ const configWithCname = extend ( { cname : host } , CONFIG ) ;
24702471
2471- file . getSignedUrl (
2472- {
2473- action : 'read' ,
2474- cname : host ,
2475- expires : Date . now ( ) + 2000 ,
2476- } ,
2477- function ( err , signedUrl ) {
2478- assert . ifError ( err ) ;
2479- assert . strictEqual ( signedUrl . indexOf ( host ) , 0 ) ;
2480- done ( ) ;
2481- }
2482- ) ;
2472+ file . getSignedUrl ( configWithCname , function ( err , signedUrl ) {
2473+ assert . ifError ( err ) ;
2474+
2475+ const expires = Math . round ( CONFIG . expires / 1000 ) ;
2476+ const expected =
2477+ 'http://www.example.com/file-name.png?' +
2478+ 'GoogleAccessId=client-email&Expires=' +
2479+ expires +
2480+ '&Signature=signature' ;
2481+
2482+ assert . equal ( signedUrl , expected ) ;
2483+ done ( ) ;
2484+ } ) ;
24832485 } ) ;
24842486
24852487 it ( 'should remove trailing slashes from cname' , function ( done ) {
You can’t perform that action at this time.
0 commit comments