codex-team / codex-team/editor.js
💡Adding mailto protocol to link in case of email
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
I thought this would be good. Currently I type in the protocol manually, though I believe it would be simple to achieve like this:
`inline-tool-link.ts - line: 364`
```js
/**
* We need to add missed HTTP protocol to the link, but skip 2 cases:
* 1) Internal links like "/general"
* 2) Anchors looks like "#results"
* 3) Protocol-relative URLs like "//google.com"
* 4) Strip the query string (if any) and check if email address
*/
const isInternal = /^\/[^/\s]/.test(link),
isAnchor = link.substring(0, 1) === '#',
isProtocolRelative = /^\/\/[^/\s]/.test(link),
isMail = link.split('?')[0].includes('@');
if (!isInternal && !isAnchor && !isProtocolRelative) {
link = isMail ? 'mailto:' + link : 'http://' + link;
}
```
I tried to fork for a PR, but for some reason, I keep getting errors trying to run the `yarn build:dev` command. Thought I would just share the idea, and have someone more experienced add it later on if liked.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.