aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/core/url_preprocessing/url_mapper.cpp
blob: 0c646ed0d68304ba2ee062692f6a11042e21a184 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "url_mapper.h"

namespace NYql {

void TUrlMapper::AddMapping(const TString& pattern, const TString& targetUrl) {
    CustomSchemes.push_back(TCustomScheme(pattern, targetUrl));
}

bool TUrlMapper::MapUrl(const TString& url, TString& mappedUrl) const {
    for (const auto& sc : CustomSchemes) {
        if (sc.Pattern.Match(url.data())) {
            mappedUrl = TRegExSubst(sc.TargetUrlSubst).Replace(url.data());
            return true;
        }
    }
    return false;
}

}