Temasys / AdapterJS

AdapterJS Javascript Polyfill and Tools for WebRTC - Skylink WebRTC
http://skylink.io/web
Other
429 stars 100 forks source link

Uncaught SyntaxError: Invalid or unexpected token #240

Closed oooookk7 closed 7 years ago

oooookk7 commented 7 years ago

It seems like there are weird characters in the script when loaded in the CDN demos. See sample demo link here. If you open the Web Console, you will see the following line:

adapter.debug.js:644 Uncaught SyntaxError: Invalid or unexpected token

Then if you click the the adapter.debug.js part in that console log line, you will have to scroll to line 644, and you will see weird characters †in the script. Here's an example of how it's like now:

// Check for browser types and react accordingly
if ( (navigator.mozGetUserMedia ||
      navigator.webkitGetUserMedia ||
      (navigator.mediaDevices &&
       navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)))
    && !((navigator.userAgent.match(/android/ig) || []).length === 0 &&
          (navigator.userAgent.match(/chrome/ig) || []).length === 0 && navigator.userAgent.indexOf('Safari/') > 0)) {

The solution right now is to set the charset="utf-8" on the <script>, or to remove these characters in grunt tasks when compiling for SkylinkJS.

johache commented 7 years ago

I feel like you should have a <meta> tag in you <head> See http://www.w3schools.com/tags/att_meta_charset.asp

Would that not fix the issue ? Seems pretty standard to me.

oooookk7 commented 7 years ago

It's true that <meta> tag is a standard (the CDN automatically adds it), but these characters should not exist in the code though.

johache commented 7 years ago

Try this version, see if that fixes the issue : https://github.com/Temasys/AdapterJS/tree/GH-240-bad-characters

johache commented 7 years ago

Ha ha, sorry, I just saw your PR

johache commented 7 years ago

PR merged : https://github.com/Temasys/AdapterJS/pull/241

oooookk7 commented 7 years ago

Too late too late!