Skip to content

Commit c3a4699

Browse files
committed
Support //# as a pragma
1 parent bcaec70 commit c3a4699

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

sourcemap/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def discover(source):
3535
possibilities = source
3636

3737
for line in set(possibilities):
38-
if line[:21] == '//@ sourceMappingURL=':
39-
# We want everything AFTER the indicator, which is 21 chars long
38+
pragma = line[:21]
39+
if pragma == '//# sourceMappingURL=' or pragma == '//@ sourceMappingURL=':
40+
# We want everything AFTER the pragma, which is 21 chars long
4041
return line[21:].rstrip()
4142
# XXX: Return None or raise an exception?
4243
return None

tests/test_init.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ def test_finds_sourcemap(self):
1212
this is some code
1313
it's really awesome
1414
//@ sourceMappingURL=file.js
15+
"""
16+
self.assertFoundSourcemap(fixture, 'file.js')
17+
18+
def test_finds_sourcemap_alt(self):
19+
fixture = """
20+
hey
21+
this is some code
22+
it's really awesome
23+
//# sourceMappingURL=file.js
1524
"""
1625
self.assertFoundSourcemap(fixture, 'file.js')
1726

0 commit comments

Comments
 (0)