fgnass/domino — Issue #6: ReferenceError when getting .src with script element in different domain
Author: lessmind
Created: 2012-02-14 02:44:25+00:00
State: open

Hi, this issue happend when there's some script source not in the same domain.
Like now I'm in http://abc.com, but the script is at http://ijk.com/some.js, and when I access its src like

```javascript
console.log(window.document.getElementsByTagName('script')[2].src)
```

Then I got errors here.

Actually they are all in the same block, so I post these together.

/path/to/domino/lib/URL.js:18
var pos = S.lastIndexOf(match[4], ":");
^
ReferenceError: S is not defined

/path/to/domino/lib/URL.js:19
this.host = substring(match[4], 0, pos);
^
ReferenceError: substring is not defined

/path/to/domino/lib/URL.js:20
this.port = substring(match[4], pos+1);
^
ReferenceError: substring is not defined

Maybe there should be some utilities been required in this module, but I can't find it though, now I modified it, and not sure if I made any other mistakes. Hope I can have some solutions here.

The original:

```javascript
var pos = S.lastIndexOf(match[4], ":");
this.host = substring(match[4], 0, pos);
this.port = substring(match[4], pos+1);
```
Modified:

```javascript
var pos = match[4].lastIndexOf(':');
this.host = match[4].substring(0, pos);
this.port = match[4].substring(pos+1);
```