Socket
Socket
Sign inDemoInstall

rehype-link-processor

Package Overview
Dependencies
4
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

./dist/index.js

2

dist/index.d.ts

@@ -64,2 +64,3 @@ import type { Root } from "hast";

prefix(prefix: string): LinkProcessorMatcherRule["match"];
email(): LinkProcessorMatcherRule["match"];
external(): LinkProcessorMatcherRule["match"];

@@ -75,2 +76,3 @@ download(options?: {

external(): LinkProcessorMatcherRule;
email(): LinkProcessorMatcherRule;
"same-page"(): LinkProcessorMatcherRule;

@@ -77,0 +79,0 @@ };

@@ -60,2 +60,10 @@ import { SKIP, visit } from "unist-util-visit";

},
email() {
return link => {
if (link.href?.startsWith("mailto:")) {
return {};
}
return M.prefix("email:")(link);
};
},
external() {

@@ -72,3 +80,3 @@ return link => {

return link => {
if (link.href) {
if (link.href?.startsWith("http:") || link.href?.startsWith("https:")) {
// check if is a file link

@@ -108,2 +116,8 @@ // check if has an extension, .1-4 char length

},
email() {
return {
match: M.email(),
action: A.mergeClass("email")
};
},
"same-page"() {

@@ -110,0 +124,0 @@ return {

2

package.json
{
"name": "rehype-link-processor",
"version": "1.0.3",
"version": "1.0.4",
"description": "rehype plugin to process links adding custom css class or attributes used by external or download links",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -128,5 +128,5 @@ # rehype-link-processor

looks for external links matching when one of:
- the url start with http: or https:
- the url start with the prefix `external:`
- the text start with the prefix `external:`
- the url starts with `http:` or `https`:
- the url starts with the prefix `external:`
- the text starts with the prefix `external:`

@@ -161,5 +161,5 @@ if matched, the resulting `a` will have the attributes:

looks for download links matching when one of:
- the url ends with `.<ext>` where `ext` is [1-4] chars long (excluded: `html`, `htm`, `md`, `mdx`)
- the url start with the prefix `download:`
- the text start with the prefix `download:`
- the url starts with `http:` or `https:` and the path ends with `.<ext>` where `ext` is [1-4] chars long (excluded: `html`, `htm`, `md`, `mdx`)
- the url starts with the prefix `download:`
- the text starts with the prefix `download:`

@@ -189,2 +189,33 @@ if matched, the resulting `a` will have the attributes:

- `email`
looks for email links matching when one of:
- the url starts with `mailto:`
- the url starts with the prefix `email:`
- the text starts with the prefix `email:`
if matched, the resulting `a` will have the attributes:
- `class` = "email"
<br />
<details>
<summary><b>Examples</b></summary>
Markdown: <br />
`[Contact us](support@domain.com)`
HTML: <br />
`<a href="mailto:support@domain.com" class="email">Contact us<a>`
***
Markdown: <br />
`[email:Send us a mail](info@domain.com)`
HTML: <br />
`<a href="mailto:info@domain.com" class="email">Send us a mail<a>`
</details>
<br />
- `same-page`

@@ -191,0 +222,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc