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

Package Sidebar

Install

npm i get-src

Weekly Downloads

6,254

Version

1.0.1

License

MIT

Last publish

Collaborators

  • radiovisual