mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-03-03 12:58:03 +01:00
Add helper function to SchemaParser to sanitise JSON Pointers (and ensure that they have consistent endings)
This commit is contained in:
parent
39da77d17e
commit
a74ce3fb2c
@ -170,6 +170,25 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitise an optional JSON Pointer, trimming trailing slashes
|
||||
*/
|
||||
std::string sanitiseJsonPointer(const boost::optional<std::string> input)
|
||||
{
|
||||
if (input) {
|
||||
// Trim trailing slash(es)
|
||||
std::string sanitised = *input;
|
||||
sanitised.erase(sanitised.find_last_not_of('/') + 1,
|
||||
std::string::npos);
|
||||
|
||||
return sanitised;
|
||||
}
|
||||
|
||||
// If the JSON Pointer is not set, assume that the URI points to
|
||||
// the root of the document
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Populate a Schema object from JSON Schema document
|
||||
*
|
||||
@ -543,8 +562,8 @@ private:
|
||||
internal::json_reference::getJsonReferenceUri(jsonRef);
|
||||
|
||||
// Extract JSON Pointer from JSON Reference
|
||||
const std::string jsonPointer =
|
||||
internal::json_reference::getJsonReferencePointer(jsonRef);
|
||||
const std::string jsonPointer = sanitiseJsonPointer(
|
||||
internal::json_reference::getJsonReferencePointer(jsonRef));
|
||||
|
||||
if (documentUri) {
|
||||
// Resolve reference against remote document
|
||||
|
Loading…
x
Reference in New Issue
Block a user