Skip to content

Commit 0935ffc

Browse files
committed
Use regex to detect image links
1 parent 2827c50 commit 0935ffc

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/paste-markdown-image-link.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ function links(transfer: DataTransfer): Array<string> {
8080
return (transfer.getData('text/uri-list') || '').split('\r\n')
8181
}
8282

83+
const IMAGE_RE = /\.(gif|png|jpe?g)$/i
84+
8385
function isImageLink(url: string): boolean {
84-
const ext = url
85-
.split('.')
86-
.pop()
87-
.toLowerCase()
88-
return ['gif', 'png', 'jpg', 'jpeg'].indexOf(ext) > -1
86+
return IMAGE_RE.test(url)
8987
}

0 commit comments

Comments
 (0)