Skip to content

Commit 9ee5cbd

Browse files
author
ironholds
committed
fix unintended (hah) bug
1 parent edeae47 commit 9ee5cbd

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: urltools
22
Type: Package
33
Title: Vectorised Tools for URL Handling and Parsing
4-
Version: 1.3.1
5-
Date: 2015-10-07
4+
Version: 1.3.2
5+
Date: 2015-10-09
66
Author: Oliver Keyes [aut, cre], Jay Jacobs [aut, cre], Mark Greenaway [ctb],
77
Bob Rudis [ctb]
88
Maintainer: Oliver Keyes <[email protected]>

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
Version 1.3.2
2+
-------------------------------------------------------------------------
3+
4+
BUG FIXES
5+
* Fixed a critical bug impacting URLs with colons in the path
6+
17
Version 1.3.1
8+
-------------------------------------------------------------------------
29

310
CHANGES
411
* suffix_refresh has been removed, since LazyData's parameters prevented it from functioning; thanks to

src/parsing.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ std::vector < std::string > parsing::domain_and_port(std::string& url){
3333
// url goes into the holding string.
3434
std::size_t port = url.find(":");
3535

36-
if(port != std::string::npos){
36+
if(port != std::string::npos && url.find("/") >= port){
3737
output[0] = url.substr(0,port);
3838
holding = url.substr(port+1);
3939
output_offset++;
@@ -47,6 +47,7 @@ std::vector < std::string > parsing::domain_and_port(std::string& url){
4747
// If there is one, that's when everything ends
4848
if(trailing_slash != std::string::npos){
4949
output[output_offset] = holding.substr(0, trailing_slash);
50+
output_offset++;
5051
url = holding.substr(trailing_slash+1);
5152
return output;
5253
}

tests/testthat/test_parsing.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,10 @@ test_that("Port handling works", {
5151
expect_that(port(url), equals("4000"))
5252
expect_that(path(url), equals(""))
5353
expect_that(parameters(url), equals("foo=bar"))
54+
})
55+
56+
test_that("Port handling does not break path handling", {
57+
url <- "https://en.wikipedia.org/wiki/File:Vice_City_Public_Radio_(logo).jpg"
58+
expect_that(port(url), equals(""))
59+
expect_that(path(url), equals("wiki/file:vice_city_public_radio_(logo).jpg"))
5460
})

0 commit comments

Comments
 (0)