Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: 'byte index is not a char boundary' #69

Closed
mischnic opened this issue Jun 23, 2021 · 4 comments · Fixed by #75
Closed

panic: 'byte index is not a char boundary' #69

mischnic opened this issue Jun 23, 2021 · 4 comments · Fixed by #75

Comments

@mischnic
Copy link
Member

mischnic commented Jun 23, 2021

Non-ASCII characters aren't handled correctly:

const SourceMap = require("@parcel/source-map").default;

const s = new SourceMap();
s.addSource("dist/rörfokus/4784.js")
console.log(s)
thread '<unnamed>' panicked at 'byte index 7 is not a char boundary; it is inside 'ö' (bytes 6..8) of `dist/rörfokus/4784.js`', parcel_sourcemap/src/utils.rs:59:60

if target.len() > 7 && "file://".eq_ignore_ascii_case(&target[0..7]) {
target_str = &target[7..];
}

This seems to be a better solution:
https://doc.rust-lang.org/std/string/struct.String.html#method.strip_prefix

@mischnic mischnic changed the title panic: 'byte index 7 is not a char boundary' panic: 'byte index is not a char boundary' Jun 23, 2021
@danieltroger
Copy link

Any updates on this?

@DeMoorJasper
Copy link
Member

Oh didn't see this issue, will look into this

@danieltroger
Copy link

Thank you for the fix! I still have the issue in 2.0.0-nightly.776+ba7d2263, do I need to update source-map separately somehow?

@mischnic
Copy link
Member Author

We'll need to release a new version of source-map and bump the version in Parcel itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants