Skip to content

Commit

Permalink
feat: add edit filepathtype support
Browse files Browse the repository at this point in the history
  • Loading branch information
ggdaltoso committed Aug 25, 2022
1 parent 6c0ca07 commit c256dfd
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,25 +396,21 @@ tester.describe("parse urls", test => {
test.expect(res.filepathtype).toBe("blob");
test.expect(res.filepath).toBe("test/index.js");

res = gitUrlParse("https://gitlab.com/a/b/c/d/blob/master/test/index.js");
test.expect(res.protocol).toBe("https");
test.expect(res.source).toBe("gitlab.com");
test.expect(res.owner).toBe("a/b/c");
test.expect(res.name).toBe("d");
test.expect(res.href).toBe("https://gitlab.com/a/b/c/d/blob/master/test/index.js");
test.expect(res.ref).toBe("master");
test.expect(res.filepathtype).toBe("blob");
test.expect(res.filepath).toBe("test/index.js");

res = gitUrlParse("https://gitlab.com/a/b/c/d/-/blob/master/test/index.js");
test.expect(res.protocol).toBe("https");
test.expect(res.source).toBe("gitlab.com");
test.expect(res.owner).toBe("a/b/c");
test.expect(res.name).toBe("d");
test.expect(res.href).toBe("https://gitlab.com/a/b/c/d/-/blob/master/test/index.js");
test.expect(res.ref).toBe("master");
test.expect(res.filepathtype).toBe("blob");
test.expect(res.filepath).toBe("test/index.js");
function testForFilepathtypeURL(type) {
res = gitUrlParse(`https://gitlab.com/a/b/c/d/${type}/master/test/index.js`);

test.expect(res.protocol).toBe("https");
test.expect(res.source).toBe("gitlab.com");
test.expect(res.owner).toBe("a/b/c");
test.expect(res.name).toBe("d");
test.expect(res.href).toBe(`https://gitlab.com/a/b/c/d/${type}/master/test/index.js`);
test.expect(res.ref).toBe("master");
test.expect(res.filepathtype).toBe(type);
test.expect(res.filepath).toBe("test/index.js");
}

// execute for raw, src, blob, and tree
['blob', 'raw', 'blob', 'tree', 'edit'].forEach(testForFilepathtypeURL);
});

// shorthand urls
Expand Down

0 comments on commit c256dfd

Please sign in to comment.