Skip to content

Commit

Permalink
fixup! [Core] Use OpenAssetIO-MediaCreation
Browse files Browse the repository at this point in the history
  • Loading branch information
foundrytom committed Aug 22, 2023
1 parent 21a0b13 commit 444ded5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "resolver.h"

#include <regex>
#include <sstream>
#include <stdexcept>
#include <thread>
Expand Down Expand Up @@ -39,6 +38,21 @@ PXR_NAMESPACE_CLOSE_SCOPE

namespace {

/*
* Replaces all occurrences of the search string in the subject with
* the supplied replacement.
*/
void replaceAllInString(std::string &subject, const std::string &search,
const std::string &replace) {
const size_t searchLength = search.length();
const size_t replaceLength = replace.length();
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {
subject.replace(pos, searchLength, replace);
pos += replaceLength;
}
}

/*
* OpenAssetIO LoggerInterface implementation
*
Expand Down Expand Up @@ -124,8 +138,7 @@ std::string resolveToPath(const openassetio::hostApi::ManagerPtr &manager,
}

// TODO(tc): Decode % escape sequences properly
static const std::regex kEncodedSpace{"%20"};
url = std::regex_replace(url, kEncodedSpace, " ");
replaceAllInString(url, "%20", " ");
return url.substr(kProtocolSize);
}

Expand Down

0 comments on commit 444ded5

Please sign in to comment.