File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,19 @@ describe('URLs validation', function() {
160160 cy . get ( '#errorMessage' ) . should ( 'have.text' , 'Invalid URL in field "codeRepository": "foo"' ) ;
161161 } ) ;
162162
163+ it ( 'errors on invalid URL that Javascript considers to be valid' , function ( ) {
164+ cy . get ( '#codemetaText' ) . then ( ( elem ) =>
165+ elem . text ( JSON . stringify ( {
166+ "@context" : "https://doi.org/10.5063/schema/codemeta-2.0" ,
167+ "@type" : "SoftwareSourceCode" ,
168+ "codeRepository" : "foo: bar" ,
169+ } ) )
170+ ) ;
171+ cy . get ( '#validateCodemeta' ) . click ( ) ;
172+
173+ cy . get ( '#errorMessage' ) . should ( 'have.text' , 'Invalid URL in field "codeRepository": "foo: bar"' ) ;
174+ } ) ;
175+
163176 it ( 'errors on non-string instead of URL' , function ( ) {
164177 cy . get ( '#codemetaText' ) . then ( ( elem ) =>
165178 elem . text ( JSON . stringify ( {
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ function trimSpaces(s) {
2929function isUrl ( s ) {
3030 try {
3131 const url = new URL ( s ) ;
32+ if ( url . origin == "null" ) {
33+ // forbids "foo: bar" as a URL, for example
34+ return false ;
35+ }
3236 return true ;
3337 } catch ( e ) {
3438 return false ;
You can’t perform that action at this time.
0 commit comments