@@ -9,6 +9,8 @@ import { saveAs } from 'file-saver'
99import escapeHTML from 'lodash/escape'
1010import unescapeHTML from 'lodash/unescape'
1111
12+ import isURL from 'validator/lib/isURL'
13+
1214import { stripTags } from '../../utils/string'
1315
1416import getUIElements from './lib/editor/ui-elements'
@@ -178,20 +180,6 @@ function slugifyWithUTF8 (text) {
178180 return newText
179181}
180182
181- export function isValidURL ( str ) {
182- const pattern = new RegExp ( '^(https?:\\/\\/)?' + // protocol
183- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
184- '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
185- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
186- '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
187- '(\\#[-a-z\\d_]*)?$' , 'i' ) // fragment locator
188- if ( ! pattern . test ( str ) ) {
189- return false
190- } else {
191- return true
192- }
193- }
194-
195183// parse meta
196184export function parseMeta ( md , edit , view , toc , tocAffix ) {
197185 let lang = null
@@ -1300,7 +1288,7 @@ const pdfPlugin = new Plugin(
13001288
13011289 ( match , utils ) => {
13021290 const pdfurl = match [ 1 ]
1303- if ( ! isValidURL ( pdfurl ) ) return match [ 0 ]
1291+ if ( ! isURL ( pdfurl ) ) return match [ 0 ]
13041292 const div = $ ( '<div class="pdf raw"></div>' )
13051293 div . attr ( 'data-pdfurl' , pdfurl )
13061294 return div [ 0 ] . outerHTML
0 commit comments