Skip to content

Commit

Permalink
fix unintended (hah) bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ironholds committed Oct 9, 2015
1 parent edeae47 commit 9ee5cbd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: urltools
Type: Package
Title: Vectorised Tools for URL Handling and Parsing
Version: 1.3.1
Date: 2015-10-07
Version: 1.3.2
Date: 2015-10-09
Author: Oliver Keyes [aut, cre], Jay Jacobs [aut, cre], Mark Greenaway [ctb],
Bob Rudis [ctb]
Maintainer: Oliver Keyes <ironholds@gmail.com>
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Version 1.3.2
-------------------------------------------------------------------------

BUG FIXES
* Fixed a critical bug impacting URLs with colons in the path

Version 1.3.1
-------------------------------------------------------------------------

CHANGES
* suffix_refresh has been removed, since LazyData's parameters prevented it from functioning; thanks to
Expand Down
3 changes: 2 additions & 1 deletion src/parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::vector < std::string > parsing::domain_and_port(std::string& url){
// url goes into the holding string.
std::size_t port = url.find(":");

if(port != std::string::npos){
if(port != std::string::npos && url.find("/") >= port){
output[0] = url.substr(0,port);
holding = url.substr(port+1);
output_offset++;
Expand All @@ -47,6 +47,7 @@ std::vector < std::string > parsing::domain_and_port(std::string& url){
// If there is one, that's when everything ends
if(trailing_slash != std::string::npos){
output[output_offset] = holding.substr(0, trailing_slash);
output_offset++;
url = holding.substr(trailing_slash+1);
return output;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test_parsing.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ test_that("Port handling works", {
expect_that(port(url), equals("4000"))
expect_that(path(url), equals(""))
expect_that(parameters(url), equals("foo=bar"))
})

test_that("Port handling does not break path handling", {
url <- "https://en.wikipedia.org/wiki/File:Vice_City_Public_Radio_(logo).jpg"
expect_that(port(url), equals(""))
expect_that(path(url), equals("wiki/file:vice_city_public_radio_(logo).jpg"))
})

0 comments on commit 9ee5cbd

Please sign in to comment.