Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

get-src

1.0.1 • Public • Published

get-src Build Status Coverage Status

Get the 'src' value from any string containing a src="" (embed, iframe, html, etc).

Install

$ npm install --save get-src

Usage

const getSrc = require('get-src');
 
getSrc('<image src="image.png" />');
//=> 'image.png'
 
getSrc('<iframe width="400" height="300" src="video.mp4"></iframe>');
//=> 'video.mp4'

API

getSrc(input)

input

Type: string

The string containing the src="" from which you want to extract the src value.

Double Quotes Only

Currently, there is only support for double quotes, meaning the value you want to extract must rest inside two double quotes:

Valid

src="this is valid"

Invalid

src='this will return undefined'

Pull requests are welcome if you want to add support for double AND single quotes.

License

MIT © Michael Wuergler

install

npm i get-src

Downloadsweekly downloads

8,115

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability