-
Notifications
You must be signed in to change notification settings - Fork 973
Conversation
f11c610
to
d93dd7c
Compare
Codecov Report
@@ Coverage Diff @@
## master #10839 +/- ##
==========================================
+ Coverage 54.21% 54.24% +0.02%
==========================================
Files 249 249
Lines 21816 21836 +20
Branches 3395 3399 +4
==========================================
+ Hits 11827 11844 +17
- Misses 9989 9992 +3
|
travis is passing now for all related tests
|
app/common/lib/siteSuggestions.js
Outdated
|
||
let location = data.get('location') || '' | ||
location = urlUtil.stripLocation(location) | ||
return location + (data.get('partitionNumber') ? '|' + data.get('partitionNumber') : '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid doing multiple lookups.
let location = data.get('location') || ''
let partitionNumber = data.get('partitionNumber')
return location + (partitionNumber ? '|' + partitionNumber : '')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
d93dd7c
to
b66f5a8
Compare
js/lib/urlutil.js
Outdated
stripLocation: (url) => { | ||
return url | ||
.replace(/\/*$/, '') // remove trailing / | ||
.replace(/#*$/, '') // remove trailing # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think you can combine these into one regex to be faster:
.replace(/\/?#?$/, '')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I saw that it would be great to first remove #
and then /
, so that would links like https://tweetdeck.twitter.com/#
become https://tweetdeck.twitter.com
.
So old code would be changed to:
return url
.replace(/#*$/, '') // remove trailing #
.replace(/\/*$/, '') // remove trailing /
where we would remove trailing # and then check new string for trailing /
This is what I put together .replace(/((#?\/?)|(\/#?))$/, '')
@bbondy What do you think about new regex?
b66f5a8
to
2664db1
Compare
Resolves brave#10826 Resolves brave#9827 Auditors: Test Plan:
2664db1
to
83b3341
Compare
Submitter Checklist:
git rebase -i
to squash commits (if needed).Resolves #10826
Resolves #9827
Auditors:
Test Plan: specified in #9827
Reviewer Checklist:
Tests