Skip to content

Commit 4b46729

Browse files
authored
Removed extra backslash when generating namespaces. Caused an issues … (#4)
* Removed extra backslash when generating namespaces. Caused an issues of too many backslashes resulting in invalid uri's * Fixing format due to Rustfmt check failing
1 parent 80485c2 commit 4b46729

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
*.txt

src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ fn process_value(
155155
graph: &mut Graph,
156156
namespace: &String,
157157
) {
158+
let ns = if namespace.ends_with("/") {
159+
namespace
160+
} else {
161+
&([namespace, "/"].join(""))
162+
};
163+
158164
if let Some(last_subject) = subject_stack.clone().back() {
159165
if let Some(prop) = property {
160166
match value {
@@ -203,15 +209,14 @@ fn process_value(
203209
));
204210

205211
for (key, val) in obj {
206-
let nested_property: Option<String> =
207-
Some(format!("{}/{}", namespace, key));
208-
process_value(subject_stack, &nested_property, val, graph, namespace);
212+
let nested_property: Option<String> = Some(format!("{}{}", ns, key));
213+
process_value(subject_stack, &nested_property, val, graph, ns);
209214
}
210215
subject_stack.pop_back();
211216
}
212217
Value::Array(arr) => {
213218
for val in arr {
214-
process_value(subject_stack, property, val, graph, namespace);
219+
process_value(subject_stack, property, val, graph, ns);
215220
}
216221
}
217222
}

0 commit comments

Comments
 (0)