summaryrefslogtreecommitdiff
path: root/src/js_errors.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-01-03 22:11:01 -0500
committerGitHub <noreply@github.com>2019-01-03 22:11:01 -0500
commitea6c9f2f365698e8120177bb7a1344e83f859180 (patch)
tree3174c0cc4004063fb626255c82fbb4ffefad5d7a /src/js_errors.rs
parent6be1164d8917b1ee40d344151f387417352fc804 (diff)
Revert "use byte array instead of string for code fetch (#1307)" (#1455)
This reverts commit e976b3e0414dc768624b77e431ee7f55b03b76a4. There is nothing technically wrong with this commit, but it's adding complexity to a big refactor (native ES modules #975). Since it's not necessary and simply a philosophical preference, I will revert for now and try to bring it back later.
Diffstat (limited to 'src/js_errors.rs')
-rw-r--r--src/js_errors.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/js_errors.rs b/src/js_errors.rs
index 59e388162..87b1db0d5 100644
--- a/src/js_errors.rs
+++ b/src/js_errors.rs
@@ -17,7 +17,7 @@ use std::collections::HashMap;
pub trait SourceMapGetter {
/// Returns the raw source map file.
- fn get_source_map(&self, script_name: &str) -> Option<Vec<u8>>;
+ fn get_source_map(&self, script_name: &str) -> Option<String>;
}
struct SourceMap {
@@ -287,9 +287,7 @@ fn parse_map_string(
}
_ => match getter.get_source_map(script_name) {
None => None,
- Some(raw_source_map) => SourceMap::from_json(
- &String::from_utf8(raw_source_map).expect("SourceMap is not utf-8"),
- ),
+ Some(raw_source_map) => SourceMap::from_json(&raw_source_map),
},
}
}
@@ -346,13 +344,13 @@ mod tests {
struct MockSourceMapGetter {}
impl SourceMapGetter for MockSourceMapGetter {
- fn get_source_map(&self, script_name: &str) -> Option<Vec<u8>> {
- let s: &[u8] = match script_name {
- "foo_bar.ts" => br#"{"sources": ["foo_bar.ts"], "mappings":";;;IAIA,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#,
- "bar_baz.ts" => br#"{"sources": ["bar_baz.ts"], "mappings":";;;IAEA,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,GAAG,GAAG,sDAAa,OAAO,2BAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC,EAAE,CAAC;IAEQ,QAAA,GAAG,GAAG,KAAK,CAAC;IAEzB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#,
+ fn get_source_map(&self, script_name: &str) -> Option<String> {
+ let s = match script_name {
+ "foo_bar.ts" => r#"{"sources": ["foo_bar.ts"], "mappings":";;;IAIA,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#,
+ "bar_baz.ts" => r#"{"sources": ["bar_baz.ts"], "mappings":";;;IAEA,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,GAAG,GAAG,sDAAa,OAAO,2BAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC,EAAE,CAAC;IAEQ,QAAA,GAAG,GAAG,KAAK,CAAC;IAEzB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#,
_ => return None,
};
- Some(s.to_vec())
+ Some(s.to_string())
}
}