garycourt / uri-js

An RFC 3986 compliant, scheme extendable URI parsing/validating/normalizing/resolving library for JavaScript
Other
305 stars 69 forks source link

undefined is not an object (evaluating 'URI.SCHEMES') #14

Closed mixophrygian closed 7 years ago

mixophrygian commented 8 years ago

Using as a dependency of oauth-signature, Line 4 /build/schemes/http.js":

URI.SCHEMES["http"] = URI.SCHEMES["https"] = is throwing this error.

yagottahavehart commented 8 years ago

@mixophrygian If you're using react-native and seeing this error (we were), it looks related to how it's requiring things. We're still debugging to figure it out... Try this out:

OLD: ///<reference path="../uri.ts"/> if (typeof COMPILED === "undefined" && typeof URI === "undefined" && typeof require === "function") var URI = require("../uri");

NEW:

var URI = require("../uri"); ///<reference path="../uri.ts"/> if (typeof COMPILED === "undefined" && typeof URI === "undefined" && typeof require === "function")

We did this in a couple places and it started to work, looking for a lasting solution now though

mixophrygian commented 8 years ago

Yes, I am having this problem in react-native, version 0.27.2 and oauth-signature version 1.3.1. Unfortunately that fix didn't resolve the issue for me.

retro commented 8 years ago

This also failing with ClojureScript compiler. It seems that COMPILED is not undefined, it's a boolean

eleanor-byhook commented 8 years ago

Welp, if you initialize URI.SCHEMES as an empty object before the http or https attributes get set, it works.

Add URI.SCHEMES = {}; to line four.

garycourt commented 7 years ago

Version 3 of URI.js has been refactored and should fix this issue.