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.0.0 to 2.1.0

dist/Anchorme.test.d.ts

3

dist/Anchorme.d.ts
import React from 'react';
import { AnchorProps } from './types';
import { AnchorProps, LinkComponent } from './types';
declare type Props = {
children: string;
linkComponent?: LinkComponent;
} & AnchorProps;
declare const _default: React.MemoExoticComponent<({ children, ...rest }: Props) => JSX.Element>;
export default _default;
export { default as Anchorme } from './Anchorme';
export { LinkComponent, LinkComponentProps } from './types';
/// <reference types="react" />
import { AnchorProps } from './types';
import { LinkComponent, LinkComponentProps } from './types';
declare type Props = {
href: string;
} & AnchorProps;
export declare const Link: ({ href, ...rest }: Props) => JSX.Element;
linkComponent?: LinkComponent;
} & LinkComponentProps;
export declare const Link: ({ href, linkComponent, ...rest }: Props) => JSX.Element;
export {};
import t,{useCallback as r,useMemo as e}from"react";import n from"anchorme";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */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://"},c=function(r){var e=r.href,n=a(r,["href"]),i=l(e);return t.createElement("a",o({},n,{href:""+i+e}),e)},f=t.memo((function(i){var l=i.children,f=a(i,["children"]),u=l,p=r((function(){var r=n.list(u);if(0===r.length)return u;var e=[],a=0;return r.forEach((function(r,n){r.start>a&&e.push(u.substring(a,r.start)),e.push(t.createElement(c,o({},f,{key:n,href:r.string}))),a=r.end})),u.length>a&&e.push(u.substring(a)),1===e.length?e[0]:e}),[u,f]),s=e((function(){return p()}),[p]);return t.createElement(t.Fragment,null,s)}));export{f as Anchorme};
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
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};

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),n=e(require("anchorme")),o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function u(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 o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}var a=/^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i,i=function(e){return function(e){return a.test(e)}(e)?"":n.validate.email(e)?"mailto:":"http://"},l=function(e){var t=e.href,n=u(e,["href"]),a=i(t);return r.createElement("a",o({},n,{href:""+a+t}),t)},c=r.memo((function(e){var a=e.children,i=u(e,["children"]),c=a,f=t.useCallback((function(){var e=n.list(c);if(0===e.length)return c;var t=[],u=0;return e.forEach((function(e,n){e.start>u&&t.push(c.substring(u,e.start)),t.push(r.createElement(l,o({},i,{key:n,href:e.string}))),u=e.end})),c.length>u&&t.push(c.substring(u)),1===t.length?t[0]:t}),[c,i]),s=t.useMemo((function(){return f()}),[f]);return r.createElement(r.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),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;
import React from 'react';
export declare type AnchorProps = Omit<React.HTMLProps<HTMLAnchorElement>, 'href'>;
export declare type LinkComponentProps = {
href: string;
} & AnchorProps;
export declare type LinkComponent = React.ElementType<LinkComponentProps>;

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

export declare const getProtocol: (input: string) => "" | "mailto:" | "http://";
export declare const getProtocol: (input: string) => string;
{
"name": "react-anchorme",
"version": "2.0.0",
"version": "2.1.0",
"description": "React component to detect links in text and make them clickable",

@@ -37,8 +37,8 @@ "repository": "https://github.com/potty/react-anchorme",

"@testing-library/jest-dom": "^5.5.0",
"@testing-library/react": "^10.0.3",
"@types/jest": "^25.2.1",
"@testing-library/react": "^11.0.2",
"@types/jest": "^26.0.13",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"eslint": "^7.0.0",

@@ -51,3 +51,3 @@ "eslint-config-prettier": "^6.11.0",

"husky": "^4.2.5",
"jest": "^25.5.1",
"jest": "^26.4.2",
"lint-staged": "^10.2.0",

@@ -60,6 +60,6 @@ "np": "^6.2.3",

"rollup-plugin-sizes": "^1.0.2",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.27.0",
"ts-jest": "^25.4.0",
"typescript": "^3.8.3"
"ts-jest": "^26.3.0",
"typescript": "^4.0.2"
},

@@ -66,0 +66,0 @@ "husky": {

@@ -50,1 +50,26 @@ # react-anchorme

```
### Custom link component
You can set custom link component that is rendered instead of default anchor element.
```jsx static
import React from 'react'
import { Anchorme, LinkComponentProps } from 'react-anchorme'
const SomeComponent = () => {
const CustomLink = (props: LinkComponentProps) => {
return (
<i>
<a {...props} />
</i>
)
}
return (
<Anchorme linkComponent={CustomLink} target="_blank" rel="noreferrer noopener">
Lorem ipsum http://example.loc dolor sit amet
</Anchorme>
)
}
```
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