aboutsummaryrefslogtreecommitdiff
path: root/mod/page.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-05-29 18:51:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-05-29 20:04:54 +0300
commitdea81cc7816a0b393564f4c1c94951dc7f4e277b (patch)
tree6f200ba5c1c67cf17b88391892908b2f9a64369d /mod/page.cxx
parentd0e23f3ff61e9fe1f790dac0c6fc0873777d0f86 (diff)
Adapt to making bpkg::url inheriting from butl::url
Diffstat (limited to 'mod/page.cxx')
-rw-r--r--mod/page.cxx38
1 files changed, 16 insertions, 22 deletions
diff --git a/mod/page.cxx b/mod/page.cxx
index e03ee4b..706d052 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -577,32 +577,26 @@ namespace brep
void TR_URL::
operator() (serializer& s) const
{
- // Strip the URL prefix for the link text.
- //
- // Note that it may not be a valid URL (see bpkg::url).
- //
- // @@ We should probably inherit bpkg::url from butl::url and make sure
- // that it is "rootfull" and the authority is present. Should we also
- // white-list the schema for security reasons? Then the offset will
- // always be: url_.string ().find ("://") + 3.
- //
- size_t p (string::npos);
+ s << TR(CLASS=label_)
+ << TH << label_ << ~TH
+ << TD
+ << SPAN(CLASS="value");
- if (butl::url::traits::find (url_) == 0) // Is it a "rootfull" URL ?
+ // Display HTTP(S) URL as link, striping the scheme prefix for the link
+ // text. Display URL with a different scheme as plain text.
+ //
+ if (casecmp (url_.scheme, "https") == 0 ||
+ casecmp (url_.scheme, "http") == 0)
{
- size_t n (url_.find (":/") + 2);
- if (url_[n] == '/' && url_[n + 1] != '\0') // Has authority?
- p = n + 1;
+ butl::url u (url_);
+ u.scheme.clear ();
+
+ s << A(HREF=url_) << u << ~A;
}
+ else
+ s << url_;
- s << TR(CLASS=label_)
- << TH << label_ << ~TH
- << TD
- << SPAN(CLASS="value")
- << A(HREF=url_)
- << (p != string::npos ? url_.c_str () + p : url_.c_str ())
- << ~A
- << ~SPAN
+ s << ~SPAN
<< SPAN_COMMENT (url_.comment)
<< ~TD
<< ~TR;