summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-06-07 21:15:45 +0300
committerA Farzat <a@farzat.xyz>2026-06-07 21:15:45 +0300
commita088bbbbd0eed36b9b4eb3d39dc9bc306d33f185 (patch)
tree4934aed69faeaa49c1b6e4efed9fb81a3fa01a34 /src/util
parentb3fe9879da5386df853c4c5d583eb040341195da (diff)
downloadrepo2markdown-a088bbbbd0eed36b9b4eb3d39dc9bc306d33f185.tar.gz
repo2markdown-a088bbbbd0eed36b9b4eb3d39dc9bc306d33f185.zip
Prioritize detection through extensions
While shebangs take priority on Unix-like systems, the shebang detection here is very basic and not guaranteed to be correct, so its use should be secondary.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/language.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/language.rs b/src/util/language.rs
index 8da45b8..f0870c8 100644
--- a/src/util/language.rs
+++ b/src/util/language.rs
@@ -63,4 +63,10 @@ mod tests {
let contents = "#!/usr/bin/env sh\necho hi";
assert_eq!(detect_language(Path::new("file"), contents), "bash");
}
+
+ #[test]
+ fn extension_overrides_shebang() {
+ let contents = "#!/bin/bash\nprint('hello')";
+ assert_eq!(detect_language(Path::new("main.py"), contents), "python");
+ }
}