Skip to content

Commit f859c76

Browse files
author
Jason Maurer
committed
Check url for undefined value & api change for secure url
1 parent 9370e22 commit f859c76

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/ParseFile.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ export default class ParseFile {
137137
* @param {Object} options An object to specify url options
138138
* @return {String}
139139
*/
140-
url(options?: { secure?: boolean }): ?string {
140+
url(options?: { forceSecure?: boolean }): ?string {
141141
options = options || {};
142-
if (options.secure) {
142+
if (!this._url) {
143+
return;
144+
}
145+
if (options.forceSecure) {
143146
return this._url.replace(/^http:\/\//i, 'https://');
144147
} else {
145148
return this._url;

src/__tests__/ParseFile-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,16 @@ describe('ParseFile', () => {
8282
var file = new ParseFile('parse.txt', { base64: 'ParseA==' });
8383
file.save().then(function(result) {
8484
expect(result).toBe(file);
85-
expect(result.url({ secure: true }))
85+
expect(result.url({ forceSecure: true }))
8686
.toBe('https://files.parsetfss.com/a/parse.txt');
8787
});
8888
});
8989

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+
9095
it('updates fields when saved', () => {
9196
var file = new ParseFile('parse.txt', { base64: 'ParseA==' });
9297
expect(file.name()).toBe('parse.txt');

0 commit comments

Comments
 (0)