Coverage Report

Created: 2023-06-07 06:59

/src/valijson/include/valijson/internal/uri.hpp
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <regex>
4
#include <string>
5
6
namespace valijson {
7
namespace internal {
8
namespace uri {
9
10
/**
11
  * @brief  Placeholder function to check whether a URI is absolute
12
  *
13
  * This function just checks for '://'
14
  */
15
inline bool isUriAbsolute(const std::string &documentUri)
16
0
{
17
0
    static const char * placeholderMarker = "://";
18
19
0
    return documentUri.find(placeholderMarker) != std::string::npos;
20
0
}
21
22
/**
23
 * @brief  Placeholder function to check whether a URI is a URN
24
 *
25
 * This function validates that the URI matches the RFC 8141 spec
26
 */
27
0
inline bool isUrn(const std::string &documentUri) {
28
0
  static const std::regex pattern(
29
0
      "^((urn)|(URN)):(?!urn:)([a-zA-Z0-9][a-zA-Z0-9-]{1,31})(:[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;=]+)+(\\?[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;:=]+){0,1}(#[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;:=]+){0,1}$");
30
31
0
  return std::regex_match(documentUri, pattern);
32
0
}
33
34
/**
35
 * Placeholder function to resolve a relative URI within a given scope
36
 */
37
inline std::string resolveRelativeUri(
38
        const std::string &resolutionScope,
39
        const std::string &relativeUri)
40
0
{
41
0
    return resolutionScope + relativeUri;
42
0
}
43
44
} // namespace uri
45
} // namespace internal
46
} // namespace valijson