0

This code is generated through BuckleScript -> JS, I can't see where the invalid character is.

However, I think that this may be an issue where UWP doesn't allow access to the internalhost as a feature, and thus is throwing an error.

I have already added a loop-back exception added the SID and that. I have run CheckNetIsolation LoopbackExempt -is -n=packageFamilyName.

function getJidFromUrl(url) {
  var match = url[
  /* path */
  0];

  if (match && !match[1]) {
    var jidString = atob(match[0]); //error line here
    return toJid(jidString);
  }
}

Unhandled exception at line *, column 5 in index.bs.js

0x800a139e - JavaScript runtime error: InvalidCharacterError

Community
  • 1
  • 1
M Sharp
  • 1
  • 2
  • Are you running this code in UWP's WebView or Winjs? Your parameter `url` is string, you catch the first character names `match`, now your `match` is a char. atob function can't run because this char not encode. You can try running this code in the browser to see what happened. – Xie Steven May 31 '19 at 03:15
  • I'm not running with either, just a blank JS Universal Windows app – M Sharp May 31 '19 at 16:18
  • So, this issue is a pure javascript issue, it's not specific to UWP. I actually have explained the reason. `Your parameter url is string, you catch the first character names match, now your match is a char. atob function can't run because this char not encode. ` – Xie Steven Jun 03 '19 at 02:43
  • What I'm getting for the first match[0], is "index.html" not a valid URI, I'm not sure where this is coming from could be the start page you enter in, or the content URI. – M Sharp Jun 03 '19 at 13:04
  • I did not understand why the `match[0]` is 'index.html', it should be a char. Please provide a [mcve] for more diagnosis. – Xie Steven Jun 05 '19 at 01:53

1 Answers1

0

Perhaps you meant to write

atob(match);

and not

atob(match[0]);

considering you're doing

var match = url[0];
Erik
  • 2,500
  • 6
  • 28
  • 49
  • I'm thinking you're sending something to `atob` that it doesn't support. What exactly is `url`, and why are you doing `url[0]`? – Erik May 29 '19 at 19:08
  • the url is a standard url string like https://blahblah.com/userjid the original function takes in the url, uses reasonreact.router to break down the url into path,search,hash, then uses atob() to get the jidstring. heres the original function in ReasonReact ```let getJidFromUrl = url => { open ReasonReactRouter; switch(url.path) { | [x] => { let jidString = atob(x); XMPP.Jid.toJid(Some(jidString)); } | _ => None }; };``` I don't know what the buckleScript compiler is doing to be honest. – M Sharp May 29 '19 at 19:48