Skip to content

Commit aafa86f

Browse files
committed
Fix support for git+https:// URLs
1 parent c8b3910 commit aafa86f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cypress/integration/validation.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ describe('URLs validation', function() {
160160
cy.get('#errorMessage').should('have.text', '');
161161
});
162162

163+
it('accepts git+https:// URLs', 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": ["git+http://example.org/", "git+http://example.com/"],
169+
}))
170+
);
171+
cy.get('#validateCodemeta').click();
172+
173+
cy.get('#errorMessage').should('have.text', '');
174+
});
175+
163176
it('errors on invalid URL', function() {
164177
cy.get('#codemetaText').then((elem) =>
165178
elem.text(JSON.stringify({

js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function trimSpaces(s) {
2929
function isUrl(s) {
3030
try {
3131
const url = new URL(s);
32-
if (url.origin == "null") {
32+
if (url.hostname == "") {
3333
// forbids "foo: bar" as a URL, for example
3434
return false;
3535
}

0 commit comments

Comments
 (0)