Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-anchorme

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-anchorme - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

2

dist/Link.d.ts

@@ -6,3 +6,3 @@ /// <reference types="react" />

} & LinkComponentProps;
export declare const Link: ({ href, linkComponent, ...rest }: Props) => JSX.Element;
export declare const Link: ({ href, linkComponent, truncate, ...rest }: Props) => JSX.Element;
export {};

@@ -1,2 +0,2 @@

import t,{useCallback as r,useMemo as e}from"react";import n from"anchorme";
import t,{useCallback as r,useMemo as n}from"react";import e from"anchorme";
/*! *****************************************************************************

@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var o=function(){return(o=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var o in r=arguments[e])Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o]);return t}).apply(this,arguments)};function a(t,r){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(e[n[o]]=t[n[o]])}return e}var i=/^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i,l=function(t){return function(t){return i.test(t)}(t)?"":n.validate.email(t)?"mailto:":"http://"},u=function(r){var e=r.href,n=r.linkComponent,i=a(r,["href","linkComponent"]),u=null!=n?n:"a",c=l(e);return t.createElement(u,o({},i,{href:""+c+e}),e)},c=t.memo((function(i){var l=i.children,c=a(i,["children"]),f=l,p=r((function(){var r=n.list(f);if(0===r.length)return f;var e=[],a=0;return r.forEach((function(r,n){r.start>a&&e.push(f.substring(a,r.start)),e.push(t.createElement(u,o({},c,{key:n,href:r.string}))),a=r.end})),f.length>a&&e.push(f.substring(a)),1===e.length?e[0]:e}),[f,c]),s=e((function(){return p()}),[p]);return t.createElement(t.Fragment,null,s)}));export{c as Anchorme};
***************************************************************************** */var o=function(){return(o=Object.assign||function(t){for(var r,n=1,e=arguments.length;n<e;n++)for(var o in r=arguments[n])Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o]);return t}).apply(this,arguments)};function i(t,r){var n={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.indexOf(e)<0&&(n[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(e=Object.getOwnPropertySymbols(t);o<e.length;o++)r.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(t,e[o])&&(n[e[o]]=t[e[o]])}return n}var a=/^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i,u=function(t){return function(t){return a.test(t)}(t)?"":e.validate.email(t)?"mailto:":"http://"},l=function(r){var n=r.href,e=r.linkComponent,a=r.truncate,l=i(r,["href","linkComponent","truncate"]),c=null!=e?e:"a",f=u(n),p=a?function(t,r){if("production"!==process.env.NODE_ENV&&r<=0)throw new Error("⚓️ maxLength should be positive number");return t.length>r?t.substring(0,r)+"…":t}(n,a):n;return t.createElement(c,o({},l,{href:""+f+n}),p)},c=t.memo((function(a){var u=a.children,c=i(a,["children"]),f=u,p=r((function(){var r=e.list(f);if(0===r.length)return f;var n=[],i=0;return r.forEach((function(r,e){r.start>i&&n.push(f.substring(i,r.start)),n.push(t.createElement(l,o({},c,{key:e,href:r.string}))),i=r.end})),f.length>i&&n.push(f.substring(i)),1===n.length?n[0]:n}),[f,c]),s=n((function(){return p()}),[p]);return t.createElement(t.Fragment,null,s)}));export{c as Anchorme};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("anchorme");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),u=r(t),a=function(){return(a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)};function l(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var u=0;for(n=Object.getOwnPropertySymbols(e);u<n.length;u++)t.indexOf(n[u])<0&&Object.prototype.propertyIsEnumerable.call(e,n[u])&&(r[n[u]]=e[n[u]])}return r}var o=/^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i,f=function(e){return function(e){return o.test(e)}(e)?"":u.default.validate.email(e)?"mailto:":"http://"},i=function(e){var t=e.href,r=e.linkComponent,u=l(e,["href","linkComponent"]),o=null!=r?r:"a",i=f(t);return n.default.createElement(o,a({},u,{href:""+i+t}),t)},c=n.default.memo((function(t){var r=t.children,o=l(t,["children"]),f=r,c=e.useCallback((function(){var e=u.default.list(f);if(0===e.length)return f;var t=[],r=0;return e.forEach((function(e,u){e.start>r&&t.push(f.substring(r,e.start)),t.push(n.default.createElement(i,a({},o,{key:u,href:e.string}))),r=e.end})),f.length>r&&t.push(f.substring(r)),1===t.length?t[0]:t}),[f,o]),s=e.useMemo((function(){return c()}),[c]);return n.default.createElement(n.default.Fragment,null,s)}));exports.Anchorme=c;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("anchorme");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),u=r(t),o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)};function a(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var u=0;for(n=Object.getOwnPropertySymbols(e);u<n.length;u++)t.indexOf(n[u])<0&&Object.prototype.propertyIsEnumerable.call(e,n[u])&&(r[n[u]]=e[n[u]])}return r}var l=/^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i,i=function(e){return function(e){return l.test(e)}(e)?"":u.default.validate.email(e)?"mailto:":"http://"},f=function(e){var t=e.href,r=e.linkComponent,u=e.truncate,l=a(e,["href","linkComponent","truncate"]),f=null!=r?r:"a",c=i(t),s=u?function(e,t){if("production"!==process.env.NODE_ENV&&t<=0)throw new Error("⚓️ maxLength should be positive number");return e.length>t?e.substring(0,t)+"…":e}(t,u):t;return n.default.createElement(f,o({},l,{href:""+c+t}),s)},c=n.default.memo((function(t){var r=t.children,l=a(t,["children"]),i=r,c=e.useCallback((function(){var e=u.default.list(i);if(0===e.length)return i;var t=[],r=0;return e.forEach((function(e,u){e.start>r&&t.push(i.substring(r,e.start)),t.push(n.default.createElement(f,o({},l,{key:u,href:e.string}))),r=e.end})),i.length>r&&t.push(i.substring(r)),1===t.length?t[0]:t}),[i,l]),s=e.useMemo((function(){return c()}),[c]);return n.default.createElement(n.default.Fragment,null,s)}));exports.Anchorme=c;
import React from 'react';
export declare type AnchorProps = Omit<React.HTMLProps<HTMLAnchorElement>, 'href'>;
export declare type AnchorProps = Omit<React.HTMLProps<HTMLAnchorElement>, 'href'> & {
truncate?: number;
};
export declare type LinkComponentProps = {

@@ -4,0 +6,0 @@ href: string;

export declare const getProtocol: (input: string) => string;
export declare const truncateText: (input: string, maxLength: number) => string;
{
"name": "react-anchorme",
"version": "2.1.1",
"version": "2.2.0",
"description": "React component to detect links in text and make them clickable",

@@ -23,3 +23,4 @@ "repository": "https://github.com/potty/react-anchorme",

"test:watch": "yarn test:coverage -- --watchAll",
"prepublishOnly": "yarn lint && yarn test && yarn clean && yarn build"
"prepublishOnly": "yarn lint && yarn test && yarn clean && yarn build",
"prepare": "husky install"
},

@@ -45,3 +46,3 @@ "files": [

"eslint": "^7.0.0",
"eslint-config-prettier": "^7.2.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.20.2",

@@ -51,6 +52,6 @@ "eslint-plugin-prettier": "^3.1.3",

"eslint-plugin-react-hooks": "^4.0.0",
"husky": "^4.2.5",
"husky": "^5.2.0",
"jest": "^26.4.2",
"lint-staged": "^10.2.0",
"np": "^6.2.3",
"np": "^7.4.0",
"prettier": "^2.0.5",

@@ -62,3 +63,3 @@ "react": "^17.0.1",

"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.29.0",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^26.3.0",

@@ -65,0 +66,0 @@ "typescript": "^4.0.2"

@@ -51,2 +51,19 @@ # react-anchorme

### Truncate
You can truncate link text by setting up `truncate` prop:
```jsx static
import React from 'react'
import { Anchorme } from 'react-anchorme'
const SomeComponent = () => {
return (
<Anchorme truncate={5}>
Lorem ipsum example.com dolor sit amet
</Anchorme>
)
}
```
### Custom link component

@@ -53,0 +70,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc