url_mapper.cpp 489 B

12345678910111213141516171819
  1. #include "url_mapper.h"
  2. namespace NYql {
  3. void TUrlMapper::AddMapping(const TString& pattern, const TString& targetUrl) {
  4. CustomSchemes.push_back(TCustomScheme(pattern, targetUrl));
  5. }
  6. bool TUrlMapper::MapUrl(const TString& url, TString& mappedUrl) const {
  7. for (const auto& sc : CustomSchemes) {
  8. if (sc.Pattern.Match(url.data())) {
  9. mappedUrl = TRegExSubst(sc.TargetUrlSubst).Replace(url.data());
  10. return true;
  11. }
  12. }
  13. return false;
  14. }
  15. }