get-src

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
get-src
001.0.16 years ago6 years agoMinified + gzip package size for get-src in KB

Readme

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