Add relative urls to the valid hyperlink url set

This commit is contained in:
Crzyrndm 2018-08-04 14:55:17 +12:00
parent 94faf01b72
commit dc7f369be9
2 changed files with 8 additions and 2 deletions

View File

@ -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();
}

View File

@ -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);