GH-1041: Move compress_path to a bif that uses normalize_path

This commit is contained in:
Tim Wojtulewicz 2020-07-06 11:24:34 -07:00
parent 3d3d5e7eb4
commit 560ee0c05e
4 changed files with 22 additions and 39 deletions

View file

@ -5157,3 +5157,14 @@ function to_json%(val: any, only_loggable: bool &default=F, field_escape_pattern
%{
return val->ToJSON(only_loggable, field_escape_pattern);
%}
## Compresses a given path by removing '..'s and the parent directory it
## references and also removing dual '/'s and extraneous '/./'s.
##
## dir: a path string, either relative or absolute.
##
## Returns: a compressed version of the input path.
function compress_path%(dir: string%): string
%{
return zeek::make_intrusive<zeek::StringVal>(normalize_path(dir->ToStdString()));
%}