Skip to content

Commit be3a7c8

Browse files
authored
Merge branch 'main' into inner-box-source
2 parents 99d02d9 + fc8af31 commit be3a7c8

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rspack_sources"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2021"
55
authors = ["h-a-n-a <andywangsy@gmail.com>", "ahabhgk <ahabhgk@gmail.com>"]
66
resolver = "2"

src/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ pub fn stream_chunks_of_combined_source_map<'a>(
743743
});
744744
if let Some(original_chunk) = original_chunk {
745745
if original_chunk.len() <= inner_chunk.len()
746-
&& &inner_chunk[..original_chunk.len()] == original_chunk
746+
&& inner_chunk.get(..original_chunk.len())
747+
== Some(original_chunk)
747748
{
748749
inner_original_column += location_in_chunk;
749750
inner_name_index = -1;

src/source_map_source.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,4 +693,45 @@ mod tests {
693693
.unwrap()
694694
);
695695
}
696+
697+
#[test]
698+
fn should_not_panic_when_check_for_an_identity_mapping() {
699+
let source = SourceMapSource::new(SourceMapSourceOptions {
700+
value: "hello world",
701+
name: "hello.txt",
702+
source_map: SourceMap::from_json(
703+
r#"{
704+
"version": 3,
705+
"sources": ["hello.txt"],
706+
"mappings": "AAAA,MAAG"
707+
}"#,
708+
)
709+
.unwrap(),
710+
original_source: Some("你好 世界".to_string()),
711+
inner_source_map: Some(
712+
SourceMap::from_json(
713+
r#"{
714+
"version": 3,
715+
"sources": ["hello world.txt"],
716+
"mappings": "AAAA,EAAE",
717+
"sourcesContent": ["你好✋世界"]
718+
}"#,
719+
)
720+
.unwrap(),
721+
),
722+
remove_original_source: false,
723+
});
724+
assert_eq!(
725+
source.map(&MapOptions::default()).unwrap(),
726+
SourceMap::from_json(
727+
r#"{
728+
"version": 3,
729+
"mappings": "AAAA,MAAE",
730+
"sources": ["hello world.txt"],
731+
"sourcesContent": ["你好✋世界"]
732+
}"#
733+
)
734+
.unwrap()
735+
);
736+
}
696737
}

0 commit comments

Comments
 (0)