1
0
mirror of synced 2025-12-11 00:48:21 +08:00

fix(console): url recognition

This commit is contained in:
surunzi
2020-01-03 11:39:43 +08:00
parent 1937c0d33e
commit c6b7a4668c
3 changed files with 124 additions and 98 deletions

View File

@@ -1239,10 +1239,6 @@ Escape special chars to be used as literals in RegExp constructors.
escapeRegExp('[licia]'); // -> '\\[licia\\]'
```
## evalCss
Eval css.
## extend
Copy all of the properties in the source objects over to the destination object.
@@ -1271,6 +1267,20 @@ Like extend, but only copies own properties over to the destination object.
extendOwn({name: 'RedHood'}, {age: 24}); // -> {name: 'RedHood', age: 24}
```
## extractUrls
Extract urls from plain text.
|Name |Type |Desc |
|------|------|---------------|
|str |string|Text to extract|
|return|array |Url list |
```javascript
const str = '[Official site: http://eustia.liriliri.io](http://eustia.liriliri.io)';
extractUrls(str); // -> ['http://eustia.liriliri.io']
```
## fileSize
Turn bytes into human readable file size.
@@ -1837,6 +1847,24 @@ Get the last element of array.
last([1, 2]); // -> 2
```
## linkify
Hyperlink urls in a string.
|Name |Type |Desc |
|-----------|--------|-------------------------|
|str |string |String to hyperlink |
|[hyperlink]|function|Function to hyperlink url|
|return |string |Result string |
```javascript
const str = 'Official site: http://eustia.liriliri.io'
linkify(str); // -> 'Official site: <a href="http://eustia.liriliri.io">http://eustia.liriliri.io</a>'
linkify(str, function (url) {
return '<a href="' + url + '" target="_blank">' + url + '</a>';
});
```
## loadJs
Inject script tag into page with given src value.
@@ -2532,23 +2560,6 @@ trim('_abc_', '_'); // -> 'abc'
trim('_abc_', ['a', 'c', '_']); // -> 'b'
```
## tryIt
Run function in a try catch.
|Name|Type |Desc |
|----|--------|---------------------|
|fn |function|Function to try catch|
|[cb]|function|Callback |
```javascript
tryIt(function () {
// Do something that might cause an error.
}, function (err, result) {
if (err) console.log(err);
});
```
## type
Determine the internal JavaScript [[Class]] of an object.