Skip to content

Commit 90955dc

Browse files
fix: remove repository link display on missing param errors (anuraghazra#4560)
* fix: remove repository link display on missing param errors * fix tests --------- Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
1 parent 92d6dfa commit 90955dc

7 files changed

Lines changed: 27 additions & 5 deletions

File tree

api/gist.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
setErrorCacheHeaders,
1212
} from "../src/common/cache.js";
1313
import { guardAccess } from "../src/common/access.js";
14-
import { retrieveSecondaryMessage } from "../src/common/error.js";
14+
import {
15+
MissingParamError,
16+
retrieveSecondaryMessage,
17+
} from "../src/common/error.js";
1518

1619
// @ts-ignore
1720
export default async (req, res) => {
@@ -102,6 +105,7 @@ export default async (req, res) => {
102105
bg_color,
103106
border_color,
104107
theme,
108+
show_repo_link: !(err instanceof MissingParamError),
105109
},
106110
}),
107111
);

api/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
setCacheHeaders,
99
setErrorCacheHeaders,
1010
} from "../src/common/cache.js";
11-
import { retrieveSecondaryMessage } from "../src/common/error.js";
11+
import {
12+
MissingParamError,
13+
retrieveSecondaryMessage,
14+
} from "../src/common/error.js";
1215
import { parseArray, parseBoolean, renderError } from "../src/common/utils.js";
1316
import { fetchStats } from "../src/fetchers/stats.js";
1417
import { isLocaleAvailable } from "../src/translations.js";
@@ -140,6 +143,7 @@ export default async (req, res) => {
140143
bg_color,
141144
border_color,
142145
theme,
146+
show_repo_link: !(err instanceof MissingParamError),
143147
},
144148
}),
145149
);

api/pin.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
setCacheHeaders,
99
setErrorCacheHeaders,
1010
} from "../src/common/cache.js";
11-
import { retrieveSecondaryMessage } from "../src/common/error.js";
11+
import {
12+
MissingParamError,
13+
retrieveSecondaryMessage,
14+
} from "../src/common/error.js";
1215
import { parseBoolean, renderError } from "../src/common/utils.js";
1316
import { fetchRepo } from "../src/fetchers/repo.js";
1417
import { isLocaleAvailable } from "../src/translations.js";
@@ -105,6 +108,7 @@ export default async (req, res) => {
105108
bg_color,
106109
border_color,
107110
theme,
111+
show_repo_link: !(err instanceof MissingParamError),
108112
},
109113
}),
110114
);

api/top-langs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
setCacheHeaders,
99
setErrorCacheHeaders,
1010
} from "../src/common/cache.js";
11-
import { retrieveSecondaryMessage } from "../src/common/error.js";
11+
import {
12+
MissingParamError,
13+
retrieveSecondaryMessage,
14+
} from "../src/common/error.js";
1215
import { parseArray, parseBoolean, renderError } from "../src/common/utils.js";
1316
import { fetchTopLanguages } from "../src/fetchers/top-languages.js";
1417
import { isLocaleAvailable } from "../src/translations.js";
@@ -163,6 +166,7 @@ export default async (req, res) => {
163166
bg_color,
164167
border_color,
165168
theme,
169+
show_repo_link: !(err instanceof MissingParamError),
166170
},
167171
}),
168172
);

api/wakatime.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
setErrorCacheHeaders,
1212
} from "../src/common/cache.js";
1313
import { guardAccess } from "../src/common/access.js";
14-
import { retrieveSecondaryMessage } from "../src/common/error.js";
14+
import {
15+
MissingParamError,
16+
retrieveSecondaryMessage,
17+
} from "../src/common/error.js";
1518

1619
// @ts-ignore
1720
export default async (req, res) => {
@@ -121,6 +124,7 @@ export default async (req, res) => {
121124
bg_color,
122125
border_color,
123126
theme,
127+
show_repo_link: !(err instanceof MissingParamError),
124128
},
125129
}),
126130
);

tests/gist.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ describe("Test /api/gist", () => {
129129
renderError({
130130
message: 'Missing params "id" make sure you pass the parameters in URL',
131131
secondaryMessage: "/api/gist?id=GIST_ID",
132+
renderOptions: { show_repo_link: false },
132133
}),
133134
);
134135
});

tests/pin.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ describe("Test /api/pin", () => {
212212
message:
213213
'Missing params "username", "repo" make sure you pass the parameters in URL',
214214
secondaryMessage: "/api/pin?username=USERNAME&amp;repo=REPO_NAME",
215+
renderOptions: { show_repo_link: false },
215216
}),
216217
);
217218
});

0 commit comments

Comments
 (0)