Last Comment Bug 279035 - canonizeUrl() ignores appended directories
: canonizeUrl() ignores appended directories
Status: RESOLVED FIXED
: fixed1.8.1
Product: Firefox
Classification: Client Software
Component: Location Bar (show other bugs)
: unspecified
: x86 Windows XP
: -- enhancement with 3 votes (vote)
: Firefox 2 beta1
Assigned To: Peter Kasting
: David P James
Mentors:
: 259707 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-01-19 13:48 PST by Michael Parker
Modified: 2006-06-19 12:15 PDT (History)
6 users (show)
mconnor: blocking‑firefox2+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix to provide new functionality (321 bytes, patch)
2005-01-19 13:58 PST, Michael Parker
no flags Details | Diff | Splinter Review
Updated patch (1.21 KB, patch)
2006-05-08 18:28 PDT, Peter Kasting
mconnor: review+
mconnor: approval‑branch‑1.8.1+
Details | Diff | Splinter Review
Patch as checked in: adding missing semicolons (1.21 KB, patch)
2006-06-15 17:38 PDT, Pam Greene
no flags Details | Diff | Splinter Review

Description Michael Parker 2005-01-19 13:48:35 PST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

The canonizeUrl() function in browser.js is responsible for automatically adding
the "http://" prefix and ".com", ".net", or ".org" suffixes to what is typed in
the Location bar, depending on what keyboard shortcut is used. This is useless,
however, when the user wishes to also enter some subdirectory or specify a
remote file for viewing (e.g., "google/scholar" + Ctrl + Enter should generate
"www.google.com/scholar" [subdirectory], and "google/images/logo.gif" + Ctrl +
Enter should generate "http://www.google.com/images/logo.gif").

Reproducible: Always

Steps to Reproduce:
1. Type in an domain name without its accompanying "http://www." prefix or
".com" suffix, followed by a slash and a directory name or file 
2. Hit CTRL + Enter

Actual Results:  
The resulting URL has its ".com" suffix appended after the directory name or
file, ont before

Expected Results:  
The resulting URL should have its ".com" suffix placed before the first slash
and the directory name or file
Comment 1 Michael Parker 2005-01-19 13:58:07 PST
Created attachment 171801 [details] [diff] [review]
fix to provide new functionality

This is from a diff from the browser.js file in the Firefox 1.0 source
Comment 2 Michael Parker 2005-01-19 21:42:55 PST
Comment on attachment 171801 [details] [diff] [review]
fix to provide new functionality

1872a1873
>       
1874c1875,1878
<	url = "http://www." + url + suffix;
---
>       var firstSlash = url.indexOf("/");
>       if (firstSlash < 0)
>         firstSlash = url.length;
>       url = "http://www." + url.substring(0, firstSlash) + suffix + url.substring(firstSlash, url.length);
Comment 3 timeless 2005-03-07 04:50:02 PST
for kicks, this should work:

url = url.replace(/(^[^\/]*)(|\/)/, "http://www.$1"+suffix+"$2");
Comment 4 Chris Wood 2006-04-04 21:12:53 PDT
WORKAROUND: The Autocomplete Manager extension (https://addons.mozilla.org/extensions/moreinfo.php?id=2300) includes a bugfix for this.
Comment 5 Peter Kasting 2006-05-07 23:26:30 PDT
Taking with hopes of updating the patch here.
Comment 6 Peter Kasting 2006-05-08 18:28:35 PDT
Created attachment 221397 [details] [diff] [review]
Updated patch

I made one change to the original patch to prevent the suffix insertion from resulting in two slashes (which is a different URL).  This is a patch against the trunk.
Comment 7 Peter Kasting 2006-06-13 14:29:46 PDT
Nominating for Fx2 B1.  This is a small patch that makes our behavior a little less braindead.
Comment 8 Peter Kasting 2006-06-13 23:50:37 PDT
Adding a target milestone to increase likelihood of search queries finding me
Comment 9 Pam Greene 2006-06-15 17:38:08 PDT
Created attachment 225803 [details] [diff] [review]
Patch as checked in: adding missing semicolons

The curious part is that it built and ran just fine without these semicolons, but it seems poor form to omit them nonetheless.
Comment 10 Pam Greene 2006-06-15 17:44:50 PDT
fixed-1.8-branch, fixed-on-trunk
Comment 11 Phil Ringnalda (:philor) 2006-06-19 12:15:45 PDT
*** Bug 259707 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.