mirror of
https://github.com/storytold/craft-anything.git
synced 2026-11-19 05:50:53 +01:00
A script's trailing sourceMappingURL annotation is found with no space, a tab or several spaces after the //#, //@ or /*# marker, as the source map standard allows; an annotation whose URL contains whitespace is ignored.
15 lines
683 B
Rust
15 lines
683 B
Rust
use craft_anything_formats::sourcemap::find_source_mapping_url;
|
|
|
|
/// Standard annotations permit zero or several whitespace characters after the marker.
|
|
#[test]
|
|
fn annotation_marker_accepts_standard_whitespace() {
|
|
for marker in ["//#", "//@", "/*#"] {
|
|
for gap in ["", " ", "\t", " \t"] {
|
|
let end = if marker.starts_with("/*") { " */" } else { "" };
|
|
assert_eq!(find_source_mapping_url(&format!("{marker}{gap}sourceMappingURL=app.js.map{end}")), Some("app.js.map".into()));
|
|
}
|
|
}
|
|
assert_eq!(find_source_mapping_url("//# sourceMappingURL=two words.map"), None);
|
|
assert_eq!(find_source_mapping_url("//# other=app.js.map"), None);
|
|
}
|