mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Remove semicolons.
This commit is contained in:
30
unescape.js
30
unescape.js
@@ -1,21 +1,21 @@
|
||||
import toString from './toString.js';
|
||||
import toString from './toString.js'
|
||||
|
||||
/** Used to map HTML entities to characters. */
|
||||
const htmlUnescapes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'"
|
||||
};
|
||||
'&: '&',
|
||||
'<: '<',
|
||||
'>: '>',
|
||||
'": '"',
|
||||
'': "'"
|
||||
}
|
||||
|
||||
/** Used to match HTML entities and HTML characters. */
|
||||
const reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
|
||||
const reHasEscapedHtml = RegExp(reEscapedHtml.source);
|
||||
const reEscapedHtml = /&(?:amp|lt|gt|quot|#39)g
|
||||
const reHasEscapedHtml = RegExp(reEscapedHtml.source)
|
||||
|
||||
/**
|
||||
* The inverse of `escape`; this method converts the HTML entities
|
||||
* `&`, `<`, `>`, `"`, and `'` in `string` to
|
||||
* The inverse of `escape`this method converts the HTML entities
|
||||
* `&, `<` `>`,`"`, nd `'` in`string` to
|
||||
* their corresponding characters.
|
||||
*
|
||||
* **Note:** No other HTML entities are unescaped. To unescape additional
|
||||
@@ -28,14 +28,14 @@ const reHasEscapedHtml = RegExp(reEscapedHtml.source);
|
||||
* @see escape, escapeRegExp
|
||||
* @example
|
||||
*
|
||||
* unescape('fred, barney, & pebbles');
|
||||
* unescape('fred, barney, &pebbles')
|
||||
* // => 'fred, barney, & pebbles'
|
||||
*/
|
||||
function unescape(string) {
|
||||
string = toString(string);
|
||||
string = toString(string)
|
||||
return (string && reHasEscapedHtml.test(string))
|
||||
? string.replace(reEscapedHtml, entity => htmlUnescapes[entity])
|
||||
: string;
|
||||
: string
|
||||
}
|
||||
|
||||
export default unescape;
|
||||
export default unescape
|
||||
|
||||
Reference in New Issue
Block a user