diff --git a/README.markdown b/README.markdown
index 959486d4..e842593f 100644
--- a/README.markdown
+++ b/README.markdown
@@ -692,13 +692,16 @@ repeat("foo", 3, "bar");
// => "foobarfoobarfoo"
```
-#### surround(string, wrap) => string
+#### surround(string, wrap[, rightWrap]) => string
-Surround a string with another string.
+Surround a string with another string(s).
```javascript
surround("foo", "ab");
// => "abfooab"
+
+surround("foo", "", "");
+// => "foo"
```
#### quote(string, quoteChar) or q(string, quoteChar) => string
diff --git a/surround.js b/surround.js
index 9cb7f7ed..43d0411f 100644
--- a/surround.js
+++ b/surround.js
@@ -1,3 +1,3 @@
-module.exports = function surround(str, wrapper) {
- return [wrapper, str, wrapper].join('');
+module.exports = function surround(str, lWwrapper, rWrapper) {
+ return [lWwrapper, str, ((rWrapper !== undefined && rWrapper !== null) ? rWrapper : lWwrapper)].join('');
};
diff --git a/tests/surround.js b/tests/surround.js
index 15363aa2..11aee90d 100644
--- a/tests/surround.js
+++ b/tests/surround.js
@@ -2,7 +2,7 @@ var equal = require('assert').equal;
var surround = require('../surround');
-test('#surround', function(){
+test('#surround', function() {
equal(surround('foo', 'ab'), 'abfooab');
equal(surround(1, 'ab'), 'ab1ab');
equal(surround(1, 2), '212');
@@ -11,5 +11,22 @@ test('#surround', function(){
equal(surround(null, 1), '11');
equal(surround('foo', ''), 'foo');
equal(surround('foo', null), 'foo');
+ equal(surround(undefined, 1), '11');
+ equal(surround('foo', undefined), 'foo');
+ equal(surround('', ''), '');
+ equal(surround(null, null), '');
+ equal(surround(undefined, undefined), '');
+ equal(surround('foo', '', ''), 'foo');
+ equal(surround(1, '', ''), '1');
+ equal(surround(1, 2, 3), '213');
+ equal(surround('foo', 1, 2), '1foo2');
+ equal(surround('foo', 1, 0), '1foo0');
+ equal(surround('', 1, 2), '12');
+ equal(surround(null, 1, 2), '12');
+ equal(surround('foo', '', ''), 'foo');
+ equal(surround('foo', null, null), 'foo');
+ equal(surround('foo', undefined, undefined), 'foo');
+ equal(surround('', '', ''), '');
+ equal(surround(null, null, null), '');
+ equal(surround(undefined, undefined, undefined), '');
});
-