The solution found to filtering pathname with customising current normalizeTme() function. For sure it is not the ideal way of fixing. It would be great if any one can guide me with better option with less number of line code.

DEMO: https://codepen.io/athimannil/pen/vojVmL

const initialLinks = [

const normalizeTme = R.replace(
  (_match, username, rest) => {
    return /^\/\d+$/.test(rest) ?
      `https://t.me/${username.toLowerCase()}` :
      `https://t.me/${username.toLowerCase()}${rest || ""}`;

const filterOwnLinks = groupUsername => {
  return R.match(
    (_match, username, rest) => {
      if (username) {
        return currentGroup.toLowerCase() !== username.toLowerCase();
      return true;

const currentGroup = "Malappuram";

const urls = R.uniq(initialLinks)
  .filter(links => {
    const matse = R.match(
    if (matse[1]) {
      return currentGroup.toLowerCase() !== matse[1].toLowerCase();
    return true;
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.17.1/ramda.min.js"></script>

  • \$\begingroup\$ @ggorlen Updated the question codepen.io/athimannil/pen/vojVmL \$\endgroup\$ – Muhammed Aug 8 '19 at 21:13
  • \$\begingroup\$ @ggorlen The code pen seems to working for me. Unfortunately I don't know how to import ramda in to the stackoverflow snippet, I have tried a lot 😔 \$\endgroup\$ – Muhammed Aug 8 '19 at 21:39
  • 1
    \$\begingroup\$ @ggorlen Yes, finally snippet is working. Thanks a lot for your help \$\endgroup\$ – Muhammed Aug 8 '19 at 22:16
  • 1
    \$\begingroup\$ Awesome. Looks great. I'd like to echo my original question: what do you mean by normalizing? I'm not entirely sure I understand what the code is supposed to do. \$\endgroup\$ – ggorlen Aug 8 '19 at 22:19
  • \$\begingroup\$ @ggorlen Actually this is part of Telegram bot. I need to remove current group related links from the array list. You can see the original code here github.com/thedevs-network/the-guard-bot/blob/develop/handlers/… \$\endgroup\$ – Muhammed Aug 8 '19 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.