Skip to content

Commit

Permalink
Fix incorrect slash usage in file paths
Browse files Browse the repository at this point in the history
This commit resolves an issue where file path delimiters were incorrectly handled when transitioning between Linux and Windows environments. The code now accurately replaces backslashes with forward slashes before URL encoding, thereby ensuring the filename is correctly split and presented.
  • Loading branch information
Barsik-sus committed Apr 16, 2024
1 parent 846aca6 commit df1e42c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions module/move/willbe/src/action/readme_health_table_renew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ mod private
// let path = table_parameters.base_path.
let example = if let Some( name ) = find_example_file( p.as_path(), &module_name )
{
let path = path.to_string_lossy().replace( "/", "\\" ).replace( "\\", "%2F" );
let file_name = name.split( "\\" ).last().unwrap();
let path = path.to_string_lossy().replace( '\\', "/" ).replace( "/", "%2F" );
let tmp = name.replace( '\\', "/" );
let file_name = tmp.split( '/' ).last().unwrap();
let name = file_name.strip_suffix( ".rs" ).unwrap();
format!( "[![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE={path}%2Fexamples%2F{file_name},RUN_POSTFIX=--example%20{name}/{})", parameters.core_url )
}
Expand Down

0 comments on commit df1e42c

Please sign in to comment.