Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
fix end with period
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Dec 8, 2016
1 parent bbcfe76 commit cd71e0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions js/lib/urlutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ const UrlUtil = {
// for cases:
// - starts with "?" or "."
// - contains "? "
// - ends with "." (and was not preceded by a /)
const case2Reg = /(^\?)|(\?.+\s)|(^\.)|(^[^\/]*\.$)/
// - ends with "." (and was not preceded by a domain or /)
const case2Reg = /(^\?)|(\?.+\s)|(^\.)|(^[^.+\..+]*[^\/]*\.$)/
// for cases, pure string
const case3Reg = /[\?\.\/\s:]/
// for cases, data:uri, view-source:uri and about
Expand Down
7 changes: 5 additions & 2 deletions test/unit/lib/urlutilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ describe('urlutil', function () {
it('is localhost (case-insensitive)', function () {
assert.equal(UrlUtil.isNotURL('LoCaLhOsT'), false)
})
it('ends with period (input contains a forward slash)', function () {
assert.equal(UrlUtil.isNotURL('https://brave.com/test/cc?_ri_=3vv-8-e.'), false)
it('ends with period (input contains a forward slash and domain)', function () {
assert.equal(UrlUtil.isNotURL('brave.com/test/cc?_ri_=3vv-8-e.'), false)
})
it('ends with period (input contains only a forward slash)', function () {
assert.equal(UrlUtil.isNotURL('brave/com/test/cc?_ri_=3vv-8-e.'), true)
})
it('is a string with whitespace but has schema', function () {
assert.equal(UrlUtil.isNotURL('https://wwww.brave.com/test space.jpg'), false)
Expand Down

0 comments on commit cd71e0e

Please sign in to comment.