File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -137,9 +137,12 @@ export default class ParseFile {
137
137
* @param {Object } options An object to specify url options
138
138
* @return {String }
139
139
*/
140
- url ( options ?: { secure ?: boolean } ) : ?string {
140
+ url ( options ?: { forceSecure ?: boolean } ) : ?string {
141
141
options = options || { } ;
142
- if ( options . secure ) {
142
+ if ( ! this . _url ) {
143
+ return ;
144
+ }
145
+ if ( options . forceSecure ) {
143
146
return this . _url . replace ( / ^ h t t p : \/ \/ / i, 'https://' ) ;
144
147
} else {
145
148
return this . _url ;
Original file line number Diff line number Diff line change @@ -82,11 +82,16 @@ describe('ParseFile', () => {
82
82
var file = new ParseFile ( 'parse.txt' , { base64 : 'ParseA==' } ) ;
83
83
file . save ( ) . then ( function ( result ) {
84
84
expect ( result ) . toBe ( file ) ;
85
- expect ( result . url ( { secure : true } ) )
85
+ expect ( result . url ( { forceSecure : true } ) )
86
86
. toBe ( 'https://files.parsetfss.com/a/parse.txt' ) ;
87
87
} ) ;
88
88
} ) ;
89
89
90
+ it ( 'returns undefined when there is no url' , ( ) => {
91
+ var file = new ParseFile ( 'parse.txt' , { base64 : 'ParseA==' } ) ;
92
+ expect ( file . url ( { forceSecure : true } ) ) . toBeUndefined ( ) ;
93
+ } ) ;
94
+
90
95
it ( 'updates fields when saved' , ( ) => {
91
96
var file = new ParseFile ( 'parse.txt' , { base64 : 'ParseA==' } ) ;
92
97
expect ( file . name ( ) ) . toBe ( 'parse.txt' ) ;
You can’t perform that action at this time.
0 commit comments