Skip to content

Commit 1dfd5b4

Browse files
authored
fix: prefer !!/blacklist-keyword- over !!/blacklist-website- for paths of URL shorteners
1 parent 0f0ed0a commit 1dfd5b4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,17 @@ export const helpers = {
151151
domain?: string,
152152
regex?: RegExp
153153
): string => {
154-
const command = action === 'watch' ? '!!/watch-' : '!!/blacklist-website-';
154+
let command = '';
155+
156+
if (action === 'watch') {
157+
command = '!!/watch-';
158+
} else if (action === 'blacklist' && !domain) {
159+
command = '!!/blacklist-website-';
160+
} else if (action === 'blacklist' && domain) {
161+
// https://chat.stackexchange.com/transcript/11540?m=67365890#67365890
162+
command = '!!/blacklist-keyword-';
163+
}
164+
155165
const alreadyDone = 'action already taken';
156166

157167
const watchValue = domain

test/index.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ describe('index helpers', () => {
145145
const watchShortenerPath = getButtonsText('watch', 'FNEuyd', false, 'goo.gl');
146146
expect(watchShortenerPath).to.be.equal('!!/watch- (?-i:FNEuyd)(?#goo.gl)');
147147

148+
const blacklistShortenerPath = getButtonsText('blacklist', 'FNEuyd', false, 'goo.gl');
149+
expect(blacklistShortenerPath).to.be.equal('!!/blacklist-keyword- (?-i:FNEuyd)(?#goo.gl)');
150+
148151
const watchBlogspotCom = getButtonsText('watch', 'abc.blogspot.com', false);
149152
const watchBlogspotDe = getButtonsText('watch', 'abc.blogspot.de', false);
150153

0 commit comments

Comments
 (0)