RusticiSoftware / TinCanJS

JavaScript library for the Experience API (Tin Can API)
http://rusticisoftware.github.io/TinCanJS/
Apache License 2.0
207 stars 115 forks source link

instantiating using `url` property on object bombing on file protocol #124

Closed bbudd closed 8 years ago

bbudd commented 8 years ago

if I do

tinCan = new TinCan({
  url: window.location.toString()
});

where window.location.toString() starts with file:, the instantiation fails.

Specifically here - when it starts with file: then matchbecomes null, and match[x] can no longer even be undefined, it throws an error.

garemoko commented 8 years ago

I except that you'll hit a bunch of other problems using content hosted at file:// Any reason not to use localhost?

brianjmiller commented 8 years ago

@bbudd @garemoko is correct, some browser implementations of CORS prevent any requests being made cross scheme, for the ones that do work cross scheme they are a limited set and almost exclusively to 'https', and if you can find one that works from a file:// scheme then you'd further have to expect the LRS to have specific headers allowing it which the spec doesn't require and I think you are unlikely to find. So we've hobbled parseURL on purpose. AFAIK the only other place we use it internally is for more URL handling, but since an LRS must be talking over HTTP we can be safe assuming http or https as the scheme for an endpoint.