blob: f6438ecca3a70c91c5df49563e8f5478d988e907 (
plain) (
blame)
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
|
#pragma once
#include <library/cpp/regex/pcre/regexp.h>
#include <util/generic/vector.h>
namespace NYql {
class TUrlMapper {
public:
void AddMapping(const TString& pattern, const TString& targetUrl);
bool MapUrl(const TString& url, TString& mappedUrl) const;
private:
struct TCustomScheme {
TCustomScheme(const TString& pattern, const TString& url)
: Pattern(pattern)
, TargetUrlHolder(url)
, TargetUrlSubst(pattern.data()) {
if (0 == TargetUrlSubst.ParseReplacement(TargetUrlHolder.data())) {
ythrow yexception() << "Bad url replacement: " << TargetUrlHolder;
}
}
TRegExMatch Pattern;
TString TargetUrlHolder;
TRegExSubst TargetUrlSubst;
};
private:
TVector<TCustomScheme> CustomSchemes;
};
}
|