Skip to content

Handle JavaScript loaded in a blob #1322

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

Merged
merged 3 commits into from
May 10, 2018
Merged

Handle JavaScript loaded in a blob #1322

merged 3 commits into from
May 10, 2018

Conversation

kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented May 9, 2018

Just ignore the SauceLabs. It's randomly failing due to timeouts, but I rebooted it few times and all browsers are green.

@kamilogorek
Copy link
Contributor Author

@CaptObvious moved your commit to this PR so I could add tests and make some minor changes :)

@kamilogorek kamilogorek requested a review from a team May 9, 2018 13:19
@kamilogorek kamilogorek changed the title Handle JavaScript loaded in a blob vol 2 Handle JavaScript loaded in a blob May 9, 2018
@benvinegar
Copy link
Contributor

Damn, nice.

@CaptObvious
Copy link
Contributor

You could have done that in the previous PR - I had the setting enabled to allow maintainers to edit it.

Out of curiousity, why .slice() over .substr()?

@kamilogorek
Copy link
Contributor Author

You could have done that in the previous PR - I had the setting enabled to allow maintainers to edit it.

I don't like to force push to someone else's forks and I had to do this, as I rebased some changes from master. Commit is still authored as yours though :)

Out of curiousity, why .slice() over .substr()?

substr cannot accept negative ranges, as slice do, which is imo more descriptive. Eg. slice(-300) is a simple "give me last 300 characters", where substr(value.length - 300) sounds more like a "give me all the characters that are left, starting at position 300 counting from the end of the value length".
I just find it easier to read :)

@CaptObvious
Copy link
Contributor

I don't like to force push to someone else's forks and I had to do this, as I rebased some changes from master. Commit is still authored as yours though :)

Fair enough :)

substr cannot accept negative ranges, as slice do, which is imo more descriptive. Eg. slice(-300) is a simple "give me last 300 characters", where substr(value.length - 300) sounds more like a "give me all the characters that are left, starting at position 300 counting from the end of the value length".
I just find it easier to read :)

Good tip, thanks! I'm fairly new to JS so I'm still in the "whatever works" phase.

// sourceMappingURL is usually at the end of the file.
source = source.substr(source.length - 300);
// We trim the source down to the last 300 characters as sourceMappingURL is always at the end of the file.
// Why 300? To be in line with: https://github.com/getsentry/sentry/blob/4af29e8f2350e20c28a6933354e4f42437b4ba42/src/sentry/lang/javascript/processor.py#L164-L175
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You spotted where I got 300 from, nice 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I'm surprised you found it! :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, nice work @CaptObvious

@kamilogorek kamilogorek merged commit b0ea98b into master May 10, 2018
@kamilogorek kamilogorek deleted the blob branch May 10, 2018 07:56
@kamilogorek
Copy link
Contributor Author

kamilogorek commented May 10, 2018

@CaptObvious released as 3.25.0

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 this pull request may close these issues.

4 participants