mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-11 13:14:28 +00:00
Change order of repositoryName and pluginName
This commit is contained in:
parent
58ad1eb635
commit
9dc9d5e4f3
@ -27,19 +27,19 @@ export type Graph = {
|
||||
};
|
||||
|
||||
export function addressToString(address: Address) {
|
||||
if (address.pluginName.includes("$")) {
|
||||
const escaped = JSON.stringify(address.pluginName);
|
||||
throw new Error(`address.pluginName must not include "\$": ${escaped}`);
|
||||
}
|
||||
if (address.repositoryName.includes("$")) {
|
||||
const escaped = JSON.stringify(address.repositoryName);
|
||||
throw new Error(`address.repositoryName must not include "\$": ${escaped}`);
|
||||
}
|
||||
if (address.pluginName.includes("$")) {
|
||||
const escaped = JSON.stringify(address.pluginName);
|
||||
throw new Error(`address.pluginName must not include "\$": ${escaped}`);
|
||||
}
|
||||
if (address.id.includes("$")) {
|
||||
const escaped = JSON.stringify(address.id);
|
||||
throw new Error(`address.id must not include "\$": ${escaped}`);
|
||||
}
|
||||
return `${address.pluginName}\$${address.repositoryName}\$${address.id}`;
|
||||
return `${address.repositoryName}\$${address.pluginName}\$${address.id}`;
|
||||
}
|
||||
|
||||
export function stringToAddress(string: string) {
|
||||
@ -49,8 +49,8 @@ export function stringToAddress(string: string) {
|
||||
throw new Error(`Input should have exactly two \$s: ${escaped}`);
|
||||
}
|
||||
return {
|
||||
pluginName: parts[0],
|
||||
repositoryName: parts[1],
|
||||
repositoryName: parts[0],
|
||||
pluginName: parts[1],
|
||||
id: parts[2],
|
||||
};
|
||||
}
|
||||
|
@ -3,13 +3,13 @@ import {addressToString, stringToAddress} from "./graph";
|
||||
describe("graph", () => {
|
||||
describe("addressToString", () => {
|
||||
const makeSimpleAddress = () => ({
|
||||
pluginName: "widgets",
|
||||
repositoryName: "megacorp/megawidget",
|
||||
pluginName: "widgets",
|
||||
id: "issue#123",
|
||||
});
|
||||
it("stringifies a simple Address", () => {
|
||||
const input = makeSimpleAddress();
|
||||
const expected = "widgets$megacorp/megawidget$issue#123";
|
||||
const expected = "megacorp/megawidget$widgets$issue#123";
|
||||
expect(addressToString(input)).toEqual(expected);
|
||||
});
|
||||
function expectRejection(attribute, value) {
|
||||
@ -30,10 +30,10 @@ describe("graph", () => {
|
||||
|
||||
describe("stringToAddress", () => {
|
||||
it("parses a simple Address-string", () => {
|
||||
const input = "widgets$megacorp/megawidget$issue#123";
|
||||
const input = "megacorp/megawidget$widgets$issue#123";
|
||||
const expected = {
|
||||
pluginName: "widgets",
|
||||
repositoryName: "megacorp/megawidget",
|
||||
pluginName: "widgets",
|
||||
id: "issue#123",
|
||||
};
|
||||
expect(stringToAddress(input)).toEqual(expected);
|
||||
@ -51,11 +51,11 @@ describe("graph", () => {
|
||||
const examples = () => [
|
||||
{
|
||||
object: {
|
||||
pluginName: "widgets",
|
||||
repositoryName: "megacorp/megawidget",
|
||||
pluginName: "widgets",
|
||||
id: "issue#123",
|
||||
},
|
||||
string: "widgets$megacorp/megawidget$issue#123",
|
||||
string: "megacorp/megawidget$widgets$issue#123",
|
||||
},
|
||||
];
|
||||
examples().forEach((example, index) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user