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
4 changes: 2 additions & 2 deletions packages/embed-plugin-url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"homepage": "https://github.com/ritz078/embed.js#readme",
"dependencies": {
"html-linkify": "1.2.2",
"just-extend": "1.1.27"
"just-extend": "1.1.27",
"linkifyjs": "^2.1.5"
}
}
13 changes: 4 additions & 9 deletions packages/embed-plugin-url/src/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import extend from "just-extend"
import linkify from "html-linkify"
import linkify from 'linkifyjs/string'

const id = "url"

export default function url(opts) {
const defaultOptions = {
attributes: {},
const defaultOptions = { }

// setting this to true will mess up characters like "
escape: false
}

const { attributes, escape } = extend({}, defaultOptions, opts)
const defaults = extend({}, defaultOptions, opts)
return {
id,
async transform(options) {
return extend({}, options, {
result: linkify(options.result, { attributes, escape })
result: linkify(options.result, defaults)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/embed-plugin-url/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ test("Plugin: url - should convert URL into anchor", async t => {

test("Plugin: url - should include attributes in URL", async t => {
const { result } = await url({
attributes: {
target: "_blank"
}
attributes: {
rel: 'nofollow'
}
}).transform({
result: "hello https://world.com"
})
Expand Down
6 changes: 3 additions & 3 deletions packages/embed-plugin-url/tests/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Snapshot report for `packages/embed-plugin-url/tests/index.test.js`
# Snapshot report for `packages\embed-plugin-url\tests\index.test.js`

The actual snapshot is saved in `index.test.js.snap`.

Expand All @@ -8,10 +8,10 @@ Generated by [AVA](https://ava.li).

> Snapshot 1

'<a href="https://a.com">https://a.com</a>'
'<a href="https://a.com" class="linkified" target="_blank">https://a.com</a>'

## Plugin: url - should include attributes in URL

> Snapshot 1

'hello <a href="https://world.com" target="_blank">https://world.com</a>'
'hello <a href="https://world.com" class="linkified" target="_blank" rel="nofollow">https://world.com</a>'
Binary file modified packages/embed-plugin-url/tests/snapshots/index.test.js.snap
Binary file not shown.