File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ import {
1616 fromJSOrdered ,
1717 getAcceptControllingResponse ,
1818 createDeepLinkPath ,
19- escapeDeepLinkPath
19+ escapeDeepLinkPath ,
20+ sanitizeUrl
2021} from "core/utils"
2122import win from "core/window"
2223
@@ -885,4 +886,31 @@ describe("utils", function() {
885886 expect ( result ) . toEqual ( "hello\\#world" )
886887 } )
887888 } )
889+
890+ describe . only ( "sanitizeUrl" , function ( ) {
891+ it ( "should sanitize a `javascript:` url" , function ( ) {
892+ const res = sanitizeUrl ( "javascript:alert('bam!')" )
893+
894+ expect ( res ) . toEqual ( "about:blank" )
895+ } )
896+
897+ it ( "should sanitize a `data:` url" , function ( ) {
898+ const res = sanitizeUrl ( `data:text/html;base64,PHNjcmlwdD5hbGVydCgiSGV
899+ sbG8iKTs8L3NjcmlwdD4=` )
900+
901+ expect ( res ) . toEqual ( "about:blank" )
902+ } )
903+
904+ it ( "should not modify a `http:` url" , function ( ) {
905+ const res = sanitizeUrl ( `http://swagger.io/` )
906+
907+ expect ( res ) . toEqual ( "http://swagger.io/" )
908+ } )
909+
910+ it ( "should not modify a `https:` url" , function ( ) {
911+ const res = sanitizeUrl ( `https://swagger.io/` )
912+
913+ expect ( res ) . toEqual ( "https://swagger.io/" )
914+ } )
915+ } )
888916} )
You can’t perform that action at this time.
0 commit comments