Skip to content

Commit 5d0a915

Browse files
committed
feat: fix FileAdapter CSV format to preserve spaces after commas (#407)
1 parent f22f84c commit 5d0a915

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/adapter/file_adapter.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,25 @@ where
147147

148148
for (ptype, ast) in ast_map {
149149
for rule in ast.get_policy() {
150-
writeln!(policies, "{}, {}", ptype, rule.join(","))
150+
writeln!(policies, "{}, {}", ptype, rule.join(", "))
151151
.map_err(|e| AdapterError(e.into()))?;
152152
}
153153
}
154154

155155
if let Some(ast_map) = m.get_model().get("g") {
156156
for (ptype, ast) in ast_map {
157157
for rule in ast.get_policy() {
158-
writeln!(policies, "{}, {}", ptype, rule.join(","))
158+
writeln!(policies, "{}, {}", ptype, rule.join(", "))
159159
.map_err(|e| AdapterError(e.into()))?;
160160
}
161161
}
162162
}
163163

164+
// Remove trailing newline to match the original file format
165+
if policies.ends_with('\n') {
166+
policies.pop();
167+
}
168+
164169
self.save_policy_file(policies).await?;
165170
Ok(())
166171
}

0 commit comments

Comments
 (0)