Closed
Bug 892942
Opened 11 years ago
Closed 11 years ago
Remove www. and m. etc from URLs in Reader Mode
Categories
(Firefox for Android Graveyard :: Reader View, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 26
People
(Reporter: nickecarlo, Assigned: nickecarlo)
References
Details
Attachments
(1 file, 1 obsolete file)
1.58 KB,
patch
|
Margaret
:
review+
|
Details | Diff | Splinter Review |
This is a follow up to bug 891446 (see comment 4).
Assignee | ||
Comment 1•11 years ago
|
||
Taking this bug. Margaret, I'm CC'ing you because for now I think you are going to review patches here and I'm going to bother you if I hit a wall. :D
Assignee: nobody → nickecarlo
Assignee | ||
Comment 2•11 years ago
|
||
Margaret, Should we get rid of only www. or should we get rid of m. and mobile. and everything else too? Looks kinda weird without m or mobile if its a mobile site.
Flags: needinfo?(margaret.leibovic)
Comment 3•11 years ago
|
||
(In reply to Nicolas Carlo [:nickecarlo] from comment #2) > Margaret, > > Should we get rid of only www. or should we get rid of m. and mobile. and > everything else too? Looks kinda weird without m or mobile if its a mobile > site. This is Ian's call, but I think it would be fine to get rid of the m. or mobile. They don't really lend more information to the domain that's displayed, since by convention, using m. or mobile. as a subdomain just changes the layout of the text, not the content. What do we do when we show URLs in the urlbar? Do we get rid of the m. or mobile. there?
Flags: needinfo?(margaret.leibovic)
Comment 4•11 years ago
|
||
We do hide them in the urlbar, although its a bit contentious with some people I think. (see bug 898855)
Comment 5•11 years ago
|
||
(In reply to :Margaret Leibovic from comment #3) > (In reply to Nicolas Carlo [:nickecarlo] from comment #2) > > Margaret, > > > > Should we get rid of only www. or should we get rid of m. and mobile. and > > everything else too? Looks kinda weird without m or mobile if its a mobile > > site. > > This is Ian's call, but I think it would be fine to get rid of the m. or > mobile. They don't really lend more information to the domain that's > displayed, since by convention, using m. or mobile. as a subdomain just > changes the layout of the text, not the content. (In reply to :Margaret Leibovic from comment #3) > (In reply to Nicolas Carlo [:nickecarlo] from comment #2) > > Margaret, > > > > Should we get rid of only www. or should we get rid of m. and mobile. and > > everything else too? Looks kinda weird without m or mobile if its a mobile > > site. > > This is Ian's call, but I think it would be fine to get rid of the m. or > mobile. They don't really lend more information to the domain that's > displayed, since by convention, using m. or mobile. as a subdomain just > changes the layout of the text, not the content. Yeah, I think we can get rid of m. as well. In Reader Mode, the URL is more there to show the name of the source of the article you're reading, not so much the kind of website it's coming from.
Assignee | ||
Comment 6•11 years ago
|
||
Added a method (_stripHost) to strip URLs of www., m., and mobile. Margaret, This patch works fine. I'm just wondering if I'm actually going about this the right way or not.
Attachment #783964 -
Flags: feedback?(margaret.leibovic)
Comment 7•11 years ago
|
||
Comment on attachment 783964 [details] [diff] [review] bug-892942 patch for feedback Review of attachment 783964 [details] [diff] [review]: ----------------------------------------------------------------- This looks good to me. It matches what we do in Java: http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/util/StringUtils.java#69 Also asking wesj for feedback in case he knows if we already have a utility for this in JS. ::: mobile/android/chrome/content/aboutReader.js @@ +579,5 @@ > > this._doc.title = error; > }, > > + _stripHost: function Reader_stripHost(host) { It would be safer to add a check at the top of this function to make sure we have a valid string, similar to the null check in the Java implementation. Something like: if (!host) { return host; } @@ +590,5 @@ > + } else if (host.startsWith("mobile")) { > + start = 7; > + } > + > + return host.substr(start); I always need to look up the difference between substr and substring... it looks like the only difference is the second parameter, so I don't think it matters which one we use here, but it might be nice to use substring, since that's consistent with our Java implementation.
Attachment #783964 -
Flags: feedback?(wjohnston)
Attachment #783964 -
Flags: feedback?(margaret.leibovic)
Attachment #783964 -
Flags: feedback+
Comment 8•11 years ago
|
||
Oh, also, if we go ahead with this approach, let's add a comment at the top of this function explaining that it's a JS version of Java's StringUtils.stripCommonSubdomains.
Comment 9•11 years ago
|
||
Comment on attachment 783964 [details] [diff] [review] bug-892942 patch for feedback Review of attachment 783964 [details] [diff] [review]: ----------------------------------------------------------------- I'm not aware of any libraries we've got to help here. Desktop's implementation is at: http://hg.mozilla.org/mozilla-central/annotate/05d3797276d3/toolkit/components/places/nsPlacesAutoComplete.js#l156 I actually think its less efficient than this, since indexOf will search the whole string for something, and startsWith SHOULD be able to bail quickly if things don't match. We should file a bug with them about that... ::: mobile/android/chrome/content/aboutReader.js @@ +588,5 @@ > + } else if (host.startsWith("m")) { > + start = 2; > + } else if (host.startsWith("mobile")) { > + start = 7; > + } In JS, you're welcome to remove these single line braces.
Updated•11 years ago
|
Attachment #783964 -
Flags: feedback?(wjohnston) → feedback+
Assignee | ||
Comment 10•11 years ago
|
||
Margaret, Wes: Thanks for the feedback. Who should I ask to do the review when I put up the patch? Margaret or Wes? :/ Or both?
Comment 11•11 years ago
|
||
(In reply to Nicolas Carlo [:nickecarlo] from comment #10) > Margaret, Wes: > > Thanks for the feedback. > > Who should I ask to do the review when I put up the patch? Margaret or Wes? > :/ Or both? Either one of us would be happy to do the review! You can choose at random, or flag us both and see who gets to it first :)
Assignee | ||
Comment 12•11 years ago
|
||
Sorry about the delay in posting this. I was away for my exams. - Addressed the feedback by both Margaret and Wes: - Added the comment for the function - Added a check to make sure host is valid - Removed the brackets from one line if statements - Changed substr to substring.
Attachment #783964 -
Attachment is obsolete: true
Attachment #789720 -
Flags: review?(wjohnston)
Attachment #789720 -
Flags: review?(margaret.leibovic)
Comment 13•11 years ago
|
||
Comment on attachment 789720 [details] [diff] [review] bug-892842.patch Review of attachment 789720 [details] [diff] [review]: ----------------------------------------------------------------- Looks good, thanks!
Attachment #789720 -
Flags: review?(wjohnston)
Attachment #789720 -
Flags: review?(margaret.leibovic)
Attachment #789720 -
Flags: review+
Comment 15•11 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/4868b76a3aa9
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Comment 16•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/4868b76a3aa9
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 26
Comment 17•11 years ago
|
||
Comment on attachment 789720 [details] [diff] [review] bug-892842.patch Review of attachment 789720 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/chrome/content/aboutReader.js @@ +590,5 @@ > + if (host.startsWith("www")) > + start = 4; > + else if (host.startsWith("m")) > + start = 2; > + else if (host.startsWith("mobile")) I'm confused. Is this ever hit? Surely we'd end up in the previous branch here.
Comment 18•11 years ago
|
||
(In reply to :Ms2ger from comment #17) > Comment on attachment 789720 [details] [diff] [review] > bug-892842.patch > > Review of attachment 789720 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: mobile/android/chrome/content/aboutReader.js > @@ +590,5 @@ > > + if (host.startsWith("www")) > > + start = 4; > > + else if (host.startsWith("m")) > > + start = 2; > > + else if (host.startsWith("mobile")) > > I'm confused. Is this ever hit? Surely we'd end up in the previous branch > here. Oof, yeah, good catch. We include periods in the StringUtils imlementation: http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/util/StringUtils.java#69 Nicolas, can you file a follow-up to fix this? You can flag me for review.
Flags: needinfo?(nickecarlo)
Assignee | ||
Comment 19•11 years ago
|
||
Oops, sorry my bad. I overlooked the periods. I can file a follow-up but I do actually get rid of periods in all these cases. For example, the one with www starts at the character at index 4 (which is the 5th character) so it skips the period as well as www. Just wondering if it is necessary and if so, is there a reasoning behind it or just for consistency between JS and Java implementations? :)
Flags: needinfo?(nickecarlo)
Comment 20•11 years ago
|
||
(In reply to Nicolas Carlo [:nickecarlo] from comment #19) > Oops, sorry my bad. I overlooked the periods. > > I can file a follow-up but I do actually get rid of periods in all these > cases. For example, the one with www starts at the character at index 4 > (which is the 5th character) so it skips the period as well as www. > > Just wondering if it is necessary and if so, is there a reasoning behind it > or just for consistency between JS and Java implementations? Yes, because the period is omitted, the "m" case will match "mobile.foo.bar" and turn it into "bile.foo.bar". Even "margaretleibovic.com" would get munged.
Assignee | ||
Comment 21•11 years ago
|
||
Oh oops. Don't want margaretleibovic.com turning into rgaretleibovic.com. I'll do a follow up today and link to it here. Sorry about this mess up.
Assignee | ||
Comment 22•11 years ago
|
||
Filed the bug here: https://bugzilla.mozilla.org/show_bug.cgi?id=906798 Will post a patch in a couple of minutes.
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•