Skip to content

Commit

Permalink
added tests and fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexglazkov9 committed Apr 29, 2018
1 parent 80d764a commit 39d2db3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/lib/urlutil.js
Expand Up @@ -150,7 +150,7 @@ const UrlUtil = {
return ''
}

input = input.trim()
input = input.trim().replace(/\s/, '%20')

input = UrlUtil.prependScheme(input)

Expand Down Expand Up @@ -430,6 +430,7 @@ const UrlUtil = {
* @return {boolean}
*/
isFileScheme: function (url) {
url = url.replace(/\s/, '%20')
return this.getScheme(url) === fileScheme
},

Expand Down
9 changes: 9 additions & 0 deletions test/unit/lib/urlutilTestComponents.js
Expand Up @@ -160,6 +160,15 @@ module.exports = {
},
'calls prependScheme': (test) => {
test.equal(urlUtil().getUrlFromInput('/file/path/to/file'), 'file:///file/path/to/file')
},
'calls url with spaces': (test) => {
test.equal(urlUtil().getUrlFromInput('https://www.google.ca/search?q=dog cat'), 'https://www.google.ca/search?q=dog%20cat')
},
'calls url with leading and trailing whitespaces': (test) => {
test.equal(urlUtil().getUrlFromInput(' https://www.google.ca/search?q=dog cat '), 'https://www.google.ca/search?q=dog%20cat')
},
'has spaces': (test) => {
test.equal(urlUtil().getUrlFromInput('/users/humphd/repos/browser-laptop/dog cat.txt'), 'file:///users/humphd/repos/browser-laptop/dog%20cat.txt')
}
},

Expand Down

0 comments on commit 39d2db3

Please sign in to comment.