From dc7f369be9a6d557fc1ad7a7c559f53e1f887736 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Sat, 4 Aug 2018 14:55:17 +1200 Subject: [PATCH] Add relative urls to the valid hyperlink url set --- source/cell/cell.cpp | 2 +- tests/cell/cell_test_suite.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 667212d8..1e26f7c8 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -360,7 +360,7 @@ hyperlink cell::hyperlink() const void cell::hyperlink(const std::string &url, const std::string &display) { - if (url.empty() || std::find(url.begin(), url.end(), ':') == url.end()) + if (url.empty()) { throw invalid_parameter(); } diff --git a/tests/cell/cell_test_suite.cpp b/tests/cell/cell_test_suite.cpp index 510786b3..0f76e2af 100644 --- a/tests/cell/cell_test_suite.cpp +++ b/tests/cell/cell_test_suite.cpp @@ -687,7 +687,6 @@ private: xlnt_assert(!cell.has_hyperlink()); xlnt_assert_throws(cell.hyperlink(), xlnt::invalid_attribute); - xlnt_assert_throws(cell.hyperlink("notaurl"), xlnt::invalid_parameter); xlnt_assert_throws(cell.hyperlink(""), xlnt::invalid_parameter); // link without optional display const std::string link1("http://example.com"); @@ -707,6 +706,13 @@ private: xlnt_assert_equals(cell.hyperlink().url(), link2); xlnt_assert_equals(cell.hyperlink().relationship().target().to_string(), link2); xlnt_assert_equals(cell.hyperlink().display(), display_txt); + // relative (local) url + const std::string local("../test_local"); + cell.hyperlink(local); + xlnt_assert(cell.has_hyperlink()); + xlnt_assert(cell.hyperlink().external()); + xlnt_assert_equals(cell.hyperlink().url(), local); + xlnt_assert_equals(cell.hyperlink().relationship().target().to_string(), local); // value int cell_test_val = 123; cell.value(cell_test_val);