Permalink
Browse files

Allow copy construction of AWS.Endpoint

  • Loading branch information...
lsegal committed Mar 12, 2013
1 parent d72b80d commit 86658902523e2a1743ed5e043c0c27fc5451a68c
Showing with 10 additions and 0 deletions.
  1. +4 −0 lib/http.js
  2. +6 −0 test/endpoint.spec.coffee
View
@@ -57,6 +57,10 @@ AWS.Endpoint = inherit({
* @param endpoint [String] the URL to construct an endpoint from
*/
constructor: function Endpoint(endpoint, config) {
+ if (typeof endpoint !== 'string') {
+ return AWS.util.copy(endpoint);
+ }
+
if (!endpoint.match(/^http/)) {
var useSSL = config && config.sslEnabled !== undefined ?
config.sslEnabled : AWS.config.sslEnabled;
@@ -14,6 +14,12 @@
AWS = require('../lib/core')
describe 'AWS.Endpoint', ->
+ it 'copy constructs Endpoint', ->
+ origEndpoint = new AWS.Endpoint('http://domain.com')
+ endpoint = new AWS.Endpoint(origEndpoint)
+ expect(endpoint).not.toBe(origEndpoint)
+ expect(endpoint.host).toEqual('domain.com')
+
it 'retains the entire endpoint as the endpoint href', ->
href = 'http://domain.com/'
endpoint = new AWS.Endpoint(href)

0 comments on commit 8665890

Please sign in to comment.