feat: throw error for invalid remotes
This commit is contained in:
parent
64f2bdb7a9
commit
40be69b50a
|
@ -11,5 +11,8 @@
|
|||
*/
|
||||
module.exports = function extractUrlAndGlobal(urlAndGlobal) {
|
||||
const index = urlAndGlobal.indexOf("@");
|
||||
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
||||
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
||||
}
|
||||
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
||||
};
|
||||
|
|
|
@ -21,4 +21,15 @@ describe("extractUrlAndGlobal", () => {
|
|||
"_"
|
||||
]);
|
||||
});
|
||||
it("should throw error if starts with @", () => {
|
||||
expect(() => extractUrlAndGlobal("@something")).toThrow();
|
||||
});
|
||||
|
||||
it("should throw error if ends with @", () => {
|
||||
expect(() => extractUrlAndGlobal("something@")).toThrow();
|
||||
});
|
||||
|
||||
it("should throw error if do not have @", () => {
|
||||
expect(() => extractUrlAndGlobal("something")).toThrow();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue