question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Match commands case-insensitively

See original GitHub issue

I cannot imagine any scenario in which anyone would want a bot to respond to /foo, /Foo and /FOO differently, so I suggest to match commands case-insensitively in Composer.command.

Usernames should be matched case-insensitively as well (#287).

Describe alternatives you’ve considered

  1. hears(/^\/foo\b/i, handler) is less readable, and doesn’t check if usernames match (ie. /foo@notMyBot still runs) and if “command” isn’t just a code block starting with slash,
  2. To achieve case-insensitivity and inspectability (router.handler) I wrote own command routing function, to be passed to Router constructor. BTW., check it out, I think you may be interested in bringing it into this repo.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Colductioncommented, Feb 12, 2022

Hey mate, you can use this permutation snippet (I’m using it already!):

function letterCasePermutation(S) {
	S = S.toLowerCase();
	let len = S.length,
		ans = [];
	const dfs = (i, res = "") => {
		if (i < len) {
			dfs(i + 1, res + S[i]);
			if (S[i] >= "a") dfs(i + 1, res + S[i].toUpperCase());
		} else ans.push(res);
	};
	dfs(0);
	return ans;
}
1reaction
MKRherecommented, Sep 12, 2022

should Composer.command check the username before trying the regex

Yes, that would be reasonable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

case-insensitive - IBM
The case-insensitive command indicates whether the matching pattern in the control list is case-sensitive or case-insensitive. The matching pattern is evaluated ...
Read more >
bash case-insensitive commands matching
One way is to use alias shell builtin, for example: alias Python='python' alias PYTHON='python' alias Python='python' alias pyThoN='python'.
Read more >
sed Case Insensitive Search Matching and Replacement
Explains how to perform a case insensitive search and replace using sed command under Linux, macOS or Unix-like operating systems.
Read more >
Case-sensitivity (The GNU Awk User's Guide)
One way to perform a case-insensitive match at a particular point in the program is to convert the data to a single case,...
Read more >
Case insensitive commands ? : r/vim - Reddit
Hey r/vim ! I've seen in many places where the user types the ex commands/functions, case insensitive, and vim automatically corrects it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found