Ruby: strip \\?\ from display paths

This commit is contained in:
Arthur Baars
2023-03-10 20:27:30 +01:00
parent 4bfcc31ef0
commit c67bfff33b
2 changed files with 4 additions and 4 deletions

View File

@@ -120,7 +120,7 @@ pub fn extract(
source: &[u8],
ranges: &[Range],
) -> () {
let path_str = format!("{}", path.display());
let path_str = normalize_path(&path);
let span = tracing::span!(
tracing::Level::TRACE,
"extract",
@@ -155,7 +155,7 @@ pub fn extract(
/// Normalizes the path according the common CodeQL specification. Assumes that
/// `path` has already been canonicalized using `std::fs::canonicalize`.
fn normalize_path(path: &Path) -> String {
pub fn normalize_path(path: &Path) -> String {
if cfg!(windows) {
// The way Rust canonicalizes paths doesn't match the CodeQL spec, so we
// have to do a bit of work removing certain prefixes and replacing

View File

@@ -252,7 +252,7 @@ fn main() -> std::io::Result<()> {
"character-decoding-error",
"Character decoding error",
)
.file(&path.to_string_lossy())
.file(&extractor::normalize_path(&path))
.message(
"Could not decode the file contents as {}: {}. The contents of the file must match the character encoding specified in the {} {}.",
&[
@@ -272,7 +272,7 @@ fn main() -> std::io::Result<()> {
diagnostics_writer.write(
diagnostics_writer
.new_entry("unknown-character-encoding", "Unknown character encoding")
.file(&path.to_string_lossy())
.file(&extractor::normalize_path(&path))
.message(
"Unknown character encoding {} in {} {}.",
&[