I am working on a url processing class and would like to access it via a constructor. For example, calling new Url("http://www.stackoverflow.com?param=value") would return different components of the url.
While I have a basic function working I am not able to use the constructor in a different file. In this case I want to call Url in url.js from runner.js.
runner.js
define(['url'], function (url) {
"use strict";
function someParsing() {
var urlText, url1;
urlText = "http://www.stackoverflow.com";
url1 = new Url(urlText);
return url1;
}
return {
someParsing: someParsing
}
});
url.js
define(function () {
"use strict";
function Url(urlText) {
return urlText;
}
return {
urlText: urlText
}
});
the error I get
TypeError: 'undefined' is not a constructor (evaluating 'new Url(urlText)')
What is the correct way to set this up so I can use the Url constructor in runner.js?