File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ var required = require('requires-port')
14
14
* @public
15
15
*/
16
16
function trimLeft ( str ) {
17
- return ( str ? str . toString ( ) : '' ) . replace ( left , '' ) ;
17
+ return ( str ? str : '' ) . toString ( ) . replace ( left , '' ) ;
18
18
}
19
19
20
20
/**
Original file line number Diff line number Diff line change @@ -42,6 +42,30 @@ describe('url-parse', function () {
42
42
global = globalVar ;
43
43
} ) ;
44
44
45
+ describe ( 'trimLeft' , function ( ) {
46
+ it ( 'is a function' , function ( ) {
47
+ assume ( parse . trimLeft ) . is . a ( 'function' ) ;
48
+ } ) ;
49
+
50
+ it ( 'removes whitespace on the left' , function ( ) {
51
+ assume ( parse . trimLeft ( ' lol' ) ) . equals ( 'lol' ) ;
52
+ } ) ;
53
+
54
+ it ( 'calls toString on a given value' , function ( ) {
55
+ //
56
+ // When users pass in `window.location` it's not an actual string
57
+ // so you can't replace on it. So it needs to be cast to a string.
58
+ //
59
+ const fake = {
60
+ toString ( ) {
61
+ return 'wat'
62
+ }
63
+ } ;
64
+
65
+ assume ( parse . trimLeft ( fake ) ) . equals ( 'wat' ) ;
66
+ } ) ;
67
+ } ) ;
68
+
45
69
describe ( 'extractProtocol' , function ( ) {
46
70
it ( 'extracts the protocol data' , function ( ) {
47
71
assume ( parse . extractProtocol ( 'http://example.com' ) ) . eql ( {
You can’t perform that action at this time.
0 commit comments