File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ let oembed = {
14
14
15
15
// build up a list of URL variations to test against because the oembed
16
16
// providers list is not always up to date with scheme or www vs non-www
17
- let base = url . replace ( / h t t p s ? : \/ \/ (?: w w w \. ) ? / , '' ) ;
17
+ let base = url . replace ( / ^ \/ \/ | ^ h t t p s ? : \/ \/ (?: w w w \. ) ? / , '' ) ;
18
18
let testUrls = [
19
19
`http://${ base } ` ,
20
20
`https://${ base } ` ,
Original file line number Diff line number Diff line change @@ -22,6 +22,23 @@ describe('API: oembed', function () {
22
22
} ) . catch ( done ) ;
23
23
} ) ;
24
24
25
+ it ( 'finds match for schema-less urls' , function ( done ) {
26
+ let requestMock = nock ( 'https://www.reddit.com' )
27
+ . get ( '/oembed' )
28
+ . query ( true )
29
+ . reply ( 200 , {
30
+ html : 'test'
31
+ } ) ;
32
+
33
+ OembedAPI . read ( { url : '//www.reddit.com/r/pics/comments/8qi5oq/breathtaking_picture_of_jupiter_with_its_moon_io/' } )
34
+ . then ( ( results ) => {
35
+ requestMock . isDone ( ) . should . be . true ;
36
+ should . exist ( results ) ;
37
+ should . exist ( results . html ) ;
38
+ done ( ) ;
39
+ } ) . catch ( done ) ;
40
+ } ) ;
41
+
25
42
it ( 'returns error for missing url' , function ( done ) {
26
43
OembedAPI . read ( { url : '' } )
27
44
. then ( ( ) => {
You can’t perform that action at this time.
0 commit comments