embedly/embedly-jquery — Issue #23: $.embedly.defaults get modified permanently every call
Author: rsattar
Created: 2012-02-10 17:55:36+00:00
State: open

It appears that embedly defaults are changed permanently by the options on every embedly request.

For example, calling **objectify** one time:

```javascript
$.embedly(postText, {
endpoint: 'objectify',
success: function(data, dict) {
console.log("this function will be called on ALL subsequent embedly requests");
});
```

Later on if I make a **oembed** style call:

```javascript
node.embedly({
method: 'after'
});
```

It fails because `$.embedly.defaults` was modified in the previous call, and the defaults got assigned a NEW default endpoint ('objectify'), as well as a NEW success function that is call for ALL subsequent embedly calls.

It turns out that the reason for this is because of this jQuery call in embedly:

```javascript
if (typeof options !== "undefined"){
settings = $.extend($.embedly.defaults, options);
}
```

Changing this to `settings = $.extend({}, $.embedly.defaults, options);` will prevent embedly defaults from being overwritten.

Currently the only workaround seems to be to **explicitly** provide all the necessary options on every call, like:

```javascript
node.embedly({
endpoint : 'oembed',
success: null,
error: null,
method: 'after'
});
```