Skip to content

Commit

Permalink
Do this in a better way
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt committed Apr 12, 2014
1 parent 9478342 commit ba7122a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/sentry/tasks/fetch_source.py
Expand Up @@ -355,10 +355,7 @@ def expand_javascript_source(data, **kwargs):
frame.function = last_state.name if last_state else state.name
frame.abs_path = abs_path
frame.filename = state.src
if state.src is None:
frame.module = UNKNOWN_MODULE
else:
frame.module = generate_module(state.src) or UNKNOWN_MODULE
frame.module = generate_module(state.src)
elif sourcemap in sourmap_idxs:
frame.data = {
'sourcemap': sourcemap,
Expand Down Expand Up @@ -391,7 +388,9 @@ def generate_module(src):
e.g. http://google.com/js/v1.0/foo/bar/baz.js -> foo/bar/baz
"""
return CLEAN_MODULE_RE.sub('', splitext(urlsplit(src).path)[0])
if src is None:
return UNKNOWN_MODULE
return CLEAN_MODULE_RE.sub('', splitext(urlsplit(src).path)[0]) or UNKNOWN_MODULE


def generate_culprit(frame):
Expand Down
1 change: 1 addition & 0 deletions tests/sentry/tasks/fetch_source/tests.py
Expand Up @@ -124,6 +124,7 @@ def test_inlined_sources(self, discover_sourcemap, fetch_url, update):

class GenerateModuleTest(TestCase):
def test_simple(self):
assert generate_module(None) == '<unknown module>'
assert generate_module('http://example.com/foo.js') == 'foo'
assert generate_module('http://example.com/foo/bar.js') == 'foo/bar'
assert generate_module('http://example.com/js/foo/bar.js') == 'foo/bar'
Expand Down

0 comments on commit ba7122a

Please sign in to comment.