Navigation Menu

Skip to content

Commit

Permalink
fix: remove reTrimSpace in favor of trim (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Apr 28, 2023
1 parent a0cb846 commit a61ec13
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/checks.yml
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup latest deno version
uses: denolib/setup-deno@v2
uses: denoland/setup-deno@main
with:
deno-version: v1.x

Expand All @@ -24,10 +24,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup latest deno version
uses: denolib/setup-deno@v2
uses: denoland/setup-deno@main
with:
deno-version: v1.x

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/update.yml
Expand Up @@ -13,7 +13,7 @@ on:
version:
description: 'Emoji Version'
required: true
default: 14
default: 15

jobs:
publish:
Expand All @@ -24,13 +24,12 @@ jobs:
uses: actions/checkout@v3

- name: Setup Deno
# uses: denoland/setup-deno@v1
uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
uses: denoland/setup-deno@main
with:
deno-version: v1.x

- name: Run Update Script
run: deno run --allow-net --allow-write ./update.ts ${{ github.event.inputs.version }}
run: deno task update ${{ github.event.inputs.version }}

- name: Run deno fmt
run: deno fmt
Expand Down
1 change: 1 addition & 0 deletions LICENSE
@@ -1,5 +1,6 @@
MIT License

Copyright (c) 2014 Daniel Bugl
Copyright (c) 2020-2023 the denosaurs team

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
8 changes: 4 additions & 4 deletions deno.lock
@@ -1,9 +1,9 @@
{
"version": "2",
"remote": {
"https://deno.land/std@0.183.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e",
"https://deno.land/std@0.183.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea",
"https://deno.land/std@0.183.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7",
"https://deno.land/std@0.183.0/testing/asserts.ts": "e16d98b4d73ffc4ed498d717307a12500ae4f2cbe668f1a215632d19fcffc22f"
"https://deno.land/std@0.184.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e",
"https://deno.land/std@0.184.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea",
"https://deno.land/std@0.184.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7",
"https://deno.land/std@0.184.0/testing/asserts.ts": "e16d98b4d73ffc4ed498d717307a12500ae4f2cbe668f1a215632d19fcffc22f"
}
}
10 changes: 3 additions & 7 deletions emoji.ts
Expand Up @@ -7,9 +7,6 @@ export { Emoji };
// Regex to parse emoji in a string - e.g. :coffee:
const reEmojiName = /:([a-zA-Z0-9_\-\+]+):/g;

// Regex to trim whitespace. (with IE8 support)
const reTrimSpace = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;

// Non spacing mark, some emoticons have them. It's the 'Variant Form',
// which provides more information so that emoticons can be rendered as
// more colorful graphics. FE0E is a unicode text version, where as FE0F
Expand All @@ -28,11 +25,10 @@ function stripColons(str: string): string {
if (colonIndex > -1) {
if (colonIndex === str.length - 1) {
str = str.substring(0, colonIndex);
return stripColons(str);
} else {
str = str.substr(colonIndex + 1);
return stripColons(str);
str = str.substring(colonIndex + 1);
}
return stripColons(str);
}

return str;
Expand Down Expand Up @@ -128,7 +124,7 @@ export function replace(
return emoji ? replace(emoji) : s;
})
.join("");
return trim ? result.replace(reTrimSpace, "") : result;
return trim ? result.trim() : result;
}

/** Replace all emoji names in a string with actual emojis. */
Expand Down
2 changes: 1 addition & 1 deletion emoji.test.ts → emoji_test.ts
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.184.0/testing/asserts.ts";
import * as emj from "./emoji.ts";

Deno.test({
Expand Down

0 comments on commit a61ec13

Please sign in to comment.