aboutsummaryrefslogtreecommitdiff
path: root/mod/build.cxx
blob: cdbaa601a4394369793f752e8dd0031e0a198ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// file      : mod/build.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <mod/build.hxx>

#include <web/mime-url-encoding.hxx>

#include <mod/utility.hxx>

namespace brep
{
  using namespace web;

  string
  build_log_url (const string& host, const dir_path& root,
                 const build& b,
                 const string* op)
  {
    // Note that '+' is the only package version character that potentially
    // needs to be url-encoded, and only in the query part of the URL. We embed
    // the package version into the URL path part and so don't encode it.
    //
    string url (host + tenant_dir (root, b.tenant).representation () +
                mime_url_encode (b.package_name.string (), false) + '/' +
                b.package_version.string () + "/log/" +
                mime_url_encode (b.configuration, false /* query */) + '/' +
                mime_url_encode (b.toolchain_name, false /* query */) + '/' +
                b.toolchain_version.string ());

    if (op != nullptr)
    {
      url += '/';
      url += *op;
    }

    return url;
  }

  string
  build_force_url (const string& host, const dir_path& root, const build& b)
  {
    // Note that '+' is the only package version character that potentially
    // needs to be url-encoded, and only in the query part of the URL. However
    // we embed the package version into the URL query part, where it is not
    // encoded by design.
    //
    return host + tenant_dir (root, b.tenant).string () +
      "?build-force&pn=" + mime_url_encode (b.package_name.string ()) +
      "&pv=" + b.package_version.string () +
      "&cf=" + mime_url_encode (b.configuration) +
      "&tn=" + mime_url_encode (b.toolchain_name) +
      "&tv=" + b.toolchain_version.string () +
      "&reason=";
  }
}