Merge pull request #329 from Crzyrndm/Issue#327

Relative hyperlinks
This commit is contained in:
Thomas Fussell 2019-06-11 20:40:36 -04:00 committed by GitHub
commit 7e22fad735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);