File tree 2 files changed +17
-0
lines changed
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() {
160
160
cy . get ( '#errorMessage' ) . should ( 'have.text' , 'Invalid URL in field "codeRepository": "foo"' ) ;
161
161
} ) ;
162
162
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
+
163
176
it ( 'errors on non-string instead of URL' , function ( ) {
164
177
cy . get ( '#codemetaText' ) . then ( ( elem ) =>
165
178
elem . text ( JSON . stringify ( {
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ function trimSpaces(s) {
29
29
function isUrl ( s ) {
30
30
try {
31
31
const url = new URL ( s ) ;
32
+ if ( url . origin == "null" ) {
33
+ // forbids "foo: bar" as a URL, for example
34
+ return false ;
35
+ }
32
36
return true ;
33
37
} catch ( e ) {
34
38
return false ;
You can’t perform that action at this time.
0 commit comments