mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 707567 - prepend http:// to URL copy selection only if at least the full hostname is selected. r=dietrich
This commit is contained in:
parent
b031938d0e
commit
c7c1004a3d
@ -43,7 +43,7 @@ var tests = [
|
||||
},
|
||||
{
|
||||
copyVal: "<example.co>m",
|
||||
copyExpected: "http://example.co"
|
||||
copyExpected: "example.co"
|
||||
},
|
||||
{
|
||||
copyVal: "e<x>ample.com",
|
||||
@ -51,7 +51,21 @@ var tests = [
|
||||
},
|
||||
{
|
||||
copyVal: "<e>xample.com",
|
||||
copyExpected: "http://e"
|
||||
copyExpected: "e"
|
||||
},
|
||||
|
||||
{
|
||||
loadURL: "http://example.com/foo",
|
||||
expectedURL: "example.com/foo",
|
||||
copyExpected: "http://example.com/foo"
|
||||
},
|
||||
{
|
||||
copyVal: "<example.com>/foo",
|
||||
copyExpected: "http://example.com"
|
||||
},
|
||||
{
|
||||
copyVal: "<example>.com/foo",
|
||||
copyExpected: "example"
|
||||
},
|
||||
|
||||
// Test that userPass is stripped out
|
||||
|
@ -510,10 +510,17 @@
|
||||
var inputVal = this.inputField.value;
|
||||
var selectedVal = inputVal.substring(this.selectionStart, this.selectionEnd);
|
||||
|
||||
// If the selection doesn't start at the beginning or URL bar is
|
||||
// modified, nothing else to do here.
|
||||
// If the selection doesn't start at the beginning or doesn't span the full domain or
|
||||
// the URL bar is modified, nothing else to do here.
|
||||
if (this.selectionStart > 0 || this.valueIsTyped)
|
||||
return selectedVal;
|
||||
// The selection doesn't span the full domain if it doesn't contain a slash and is
|
||||
// followed by some character other than a slash.
|
||||
if (selectedVal.indexOf("/") == -1) {
|
||||
let remainder = inputVal.replace(selectedVal, "");
|
||||
if (remainder != "" && remainder[0] != "/")
|
||||
return selectedVal;
|
||||
}
|
||||
|
||||
let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user