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

Sourcemap regex, not working in windows #1200

Closed
chandru9279 opened this issue Oct 3, 2014 · 4 comments · Fixed by #1201 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed

Sourcemap regex, not working in windows #1200

chandru9279 opened this issue Oct 3, 2014 · 4 comments · Fixed by #1201 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132

Comments

@chandru9279
Copy link

I'm using karma-bro.

Im getting callstacks

ReferenceError: Can't find variable: CustomVar at http://localhost:9000/absoluteC:/Users/Zasz/AppData/Local/Temp/a08f24cea0a6c2e347f78175362d890cf06e8561.browserify?da39a3ee5e6b4b0d3255bfef95601890afd80709:247"

I can see that you are using the regex to rewrite callstacks:

 /http:\/\/[^\/]*\/(base|absolute)([^\?\s\:]*)(\?\w*)?(\:(\d+))?(\:(\d+))?/g

The regex fails - the path, line and column not detected properly on my machine - so I don't get sourcemap replacement in my callstack.

Here is a test case, you can run this in browser for quick check :

var b =  function(_, prefix, path, __, ___, line, ____, column) {
 console.log("Prefix " + prefix)
 console.log("Path " + path)
 console.log("Line " + line)
 console.log("Col " + column)
 };

 var a = "ReferenceError: Can't find variable: Customvar at http://localhost:9000/absoluteC:/Users/Zasz/AppData/Local/Temp/a08f24cea0a6c2e347f78175362d890cf06e8561.browserify?da39a3ee5e6b4b0d3255bfef95601890afd80709:247";


 var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*\\/' +
                              '(base|absolute)' + // prefix
                              '([^\\?\\s\\:]*)' + // path
                              '(\\?\\w*)?' +      // sha
                              '(\\:(\\d+))?' +    // line
                              '(\\:(\\d+))?' +    // column
                              '', 'g');

a.replace(URL_REGEXP, b);

@chandru9279 chandru9279 changed the title Sourcemap regex, not Sourcemap regex, not working in windows Oct 3, 2014
@chandru9279
Copy link
Author

If I remove the \\: from the path '([^\\?\\s\\:]*)' + // path it seems to work, any context on why we are looking for "Not colon" to get path? Isn't "Not Questionmark, and not whitespace" enough?

d7c31f9

@maksimr
Copy link
Contributor

maksimr commented Oct 4, 2014

@chandru9279 no because url may not contain sha but contain line and column

@maksimr
Copy link
Contributor

maksimr commented Oct 4, 2014

@chandru9279 fix from PR should fix it

@chandru9279
Copy link
Author

Thanks!

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