Skip to content

Commit

Permalink
Allow using mailto: links in e-mail buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
k-nut committed Nov 6, 2024
1 parent 86e45f6 commit ea62cbb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"timezones-list": "^3.0.2",
"tsconfig-paths": "^4.1.2",
"unified": "^10.1.2",
"validator": "^13.6.0",
"validator": "^13.12.0",
"xlsx": "^0.18.5",
"xlsx-js-style": "^1.2.0",
"yaml": "^1.10.0",
Expand Down Expand Up @@ -127,7 +127,7 @@
"@types/random-seed": "^0.3.3",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"@types/validator": "^13.6.3",
"@types/validator": "^13.12.2",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"babel-loader": "^8.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ describe('formatUrl()', () => {
const formatted = formatUrl('Angela');
expect(formatted).toEqual(null);
});

it('does nothing with a valid mailto: url', () => {
const formatted = formatUrl('mailto:test@example.org');
expect(formatted).toEqual('mailto:test@example.org');
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import isURL from 'validator/lib/isURL';
import isMailtoURI from 'validator/lib/isMailtoURI';

export default function formatUrl(url: string): string | null {
if (isMailtoURI(url)) {
return url;
}

if (isURL(url, { require_protocol: true })) {
return url;
}
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4746,10 +4746,10 @@
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.8.tgz#7545ba4fc3c003d6c756f651f3bf163d8f0f29ba"
integrity sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==

"@types/validator@^13.6.3":
version "13.7.0"
resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.7.0.tgz#fa25263656d234473025c2d48249a900053c355a"
integrity sha512-+jBxVvXVuggZOrm04NR8z+5+bgoW4VZyLzUO+hmPPW1mVFL/HaitLAkizfv4yg9TbG8lkfHWVMQ11yDqrVVCzA==
"@types/validator@^13.12.2":
version "13.12.2"
resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.12.2.tgz#760329e756e18a4aab82fc502b51ebdfebbe49f5"
integrity sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==

"@types/webidl-conversions@*":
version "7.0.3"
Expand Down Expand Up @@ -15509,10 +15509,10 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

validator@^13.6.0:
version "13.7.0"
resolved "https://registry.yarnpkg.com/validator/-/validator-13.7.0.tgz#4f9658ba13ba8f3d82ee881d3516489ea85c0857"
integrity sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw==
validator@^13.12.0:
version "13.12.0"
resolved "https://registry.yarnpkg.com/validator/-/validator-13.12.0.tgz#7d78e76ba85504da3fee4fd1922b385914d4b35f"
integrity sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==

vary@^1, vary@~1.1.2:
version "1.1.2"
Expand Down

0 comments on commit ea62cbb

Please sign in to comment.