COLLECTED BY
Organization:
Internet Archive
Focused crawls are collections of frequently-updated webcrawl data from narrow (as opposed to broad or wide) web crawls, often focused on a single domain or subdomain.
The Wayback Machine - https://web.archive.org/web/20201220222610/https://github.com/lodash/lodash/blob/master/unescape.js
Permalink
Cannot retrieve contributors at this time
38 lines (35 sloc)
1.09 KB
/** Used to map HTML entities to characters. */
const htmlUnescapes = {
'&' : '&' ,
'<' : '<' ,
'>' : '>' ,
'"' : '"' ,
''' : "'"
}
/** Used to match HTML entities and HTML characters. */
const reEscapedHtml = /&(?: amp| lt| gt| quot| #( 0+ ) ?39) ;/g
const reHasEscapedHtml = RegExp ( reEscapedHtml . source )
/**
* The inverse of `escape`this method converts the HTML entities
* `&`, `<`, `>`, `"` and `'` in `string` to
* their corresponding characters.
*
* **Note:** No other HTML entities are unescaped. To unescape additional
* HTML entities use a third-party library like [_he_](https://mths.be/he).
*
* @since 0.6.0
* @category String
* @param {string } [string=''] The string to unescape.
* @returns {string } Returns the unescaped string.
* @see escape, escapeRegExp
* @example
*
* unescape('fred, barney, & pebbles')
* // => 'fred, barney, & pebbles'
*/
function unescape ( string ) {
return ( string && reHasEscapedHtml . test ( string ) )
? string . replace ( reEscapedHtml , ( entity ) => ( htmlUnescapes [ entity ] || "'" ) )
: ( string || '' )
}
export default unescape
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.