Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ app.mount('#app')

You can use the [linkify options](https://linkify.js.org/docs/options.html).

### Define XSS Options

```vue
<template>
<div v-linkify:options="{
xssOptions: {
whiteList: {
span: ['style'],
}
},
}">
...
</div>
</template>
```

You can use the [xss options](https://jsxss.com/en/options#customize-whitelist).

### Add event listener

```vue
Expand Down
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { App, Directive } from "@vue/runtime-core";
import linkifyHtml from "linkify-html";
import { Options } from "linkifyjs";
import xss from "xss";
import xss, { IFilterXSSOptions } from "xss";

const linkify = (rawHtml: string, options: Options): string => {
const sanitized = xss(rawHtml);
interface VueLinkifyOptions extends Options {
xssOptions?: IFilterXSSOptions;
}

const linkify = (rawHtml: string, options: VueLinkifyOptions): string => {
const sanitized = xss(rawHtml, options.xssOptions);
return linkifyHtml(sanitized, options);
};

Expand Down