Merge lp:~daker/webbrowser-app/fix.1166063 into lp:webbrowser-app

Proposed by Adnane Belmadiaf
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 304
Merged at revision: 308
Proposed branch: lp:~daker/webbrowser-app/fix.1166063
Merge into: lp:webbrowser-app
Diff against target: 36 lines (+15/-0)
2 files modified
src/app/AddressBar.qml (+3/-0)
tests/unittests/qml/tst_AddressBar.qml (+12/-0)
To merge this branch: bzr merge lp:~daker/webbrowser-app/fix.1166063
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Olivier Tilloy Approve
Review via email: mp+185391@code.launchpad.net

Commit message

Added support for IP adresses

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for tackling this bug!

A couple of remarks:

 - I think using a regular expression to match an IP address would be more efficient. A simple regexp would be enough (no need to validate that the four components are in the range 0-255, if they are not it’s very likely a typo and the user will realize it and correct it).

 - Can you add a unit test for IP addresses in tests/unittests/qml/tst_AddressBar.qml ?

Revision history for this message
Adnane Belmadiaf (daker) wrote :

Sure i'll fix it

lp:~daker/webbrowser-app/fix.1166063 updated
304. By Adnane Belmadiaf

Fixed regexp for ip addresses
Added unit test for the ip addresses

Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks perfect, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/AddressBar.qml'
2--- src/app/AddressBar.qml 2013-08-08 16:32:40 +0000
3+++ src/app/AddressBar.qml 2013-09-15 17:17:42 +0000
4@@ -134,6 +134,9 @@
5 if (address.split('/', 1)[0].match(/\.[a-z]{2,4}$/)) {
6 return true
7 }
8+ if (address.split('/', 1)[0].match(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/)) {
9+ return true
10+ }
11 return false
12 }
13
14
15=== modified file 'tests/unittests/qml/tst_AddressBar.qml'
16--- tests/unittests/qml/tst_AddressBar.qml 2013-07-18 12:04:50 +0000
17+++ tests/unittests/qml/tst_AddressBar.qml 2013-09-15 17:17:42 +0000
18@@ -47,6 +47,18 @@
19 compare(addressBar.requestedUrl, "http://ubuntu.com")
20 }
21
22+ function test_no_ipadress_scheme_rewrite() {
23+ addressBar.text = "192.168.1.1"
24+ addressBar.validate()
25+ compare(addressBar.requestedUrl, "http://192.168.1.1")
26+ addressBar.text = "192.168.1.1:8000"
27+ addressBar.validate()
28+ compare(addressBar.requestedUrl, "http://192.168.1.1:8000")
29+ addressBar.text = "192.168.1.1:8000/dummy.html"
30+ addressBar.validate()
31+ compare(addressBar.requestedUrl, "http://192.168.1.1:8000/dummy.html")
32+ }
33+
34 function test_unhandled_scheme_no_rewrite() {
35 addressBar.text = "ftp://ubuntu.com"
36 addressBar.validate()

Subscribers

People subscribed via source and target branches

to status/vote changes: