Travis build: 732 [ci skip]
This commit is contained in:
29
README.md
29
README.md
@ -219,6 +219,7 @@
|
|||||||
* [`escapeHTML`](#escapehtml)
|
* [`escapeHTML`](#escapehtml)
|
||||||
* [`escapeRegExp`](#escaperegexp)
|
* [`escapeRegExp`](#escaperegexp)
|
||||||
* [`fromCamelCase`](#fromcamelcase)
|
* [`fromCamelCase`](#fromcamelcase)
|
||||||
|
* [`isAbsoluteURL`](#isabsoluteurl)
|
||||||
* [`palindrome`](#palindrome)
|
* [`palindrome`](#palindrome)
|
||||||
* [`repeatString`](#repeatstring)
|
* [`repeatString`](#repeatstring)
|
||||||
* [`reverseString`](#reversestring)
|
* [`reverseString`](#reversestring)
|
||||||
@ -3574,6 +3575,30 @@ fromCamelCase('someJavascriptProperty', '_'); // 'some_javascript_property'
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### isAbsoluteURL
|
||||||
|
|
||||||
|
Returns `true` if the given string is an absolute URL, `false` otherwise.
|
||||||
|
|
||||||
|
Use a regular expression to test if the string is an absolute URL.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
isAbsoluteURL('https://google.com'); // true
|
||||||
|
isAbsoluteURL('ftp://www.myserver.net'); // true
|
||||||
|
isAbsoluteURL('/foo/bar'); // false
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### palindrome
|
### palindrome
|
||||||
|
|
||||||
Returns `true` if the given string is a palindrome, `false` otherwise.
|
Returns `true` if the given string is a palindrome, `false` otherwise.
|
||||||
@ -4221,13 +4246,13 @@ isSymbol(Symbol('x')); // true
|
|||||||
|
|
||||||
Checks if the provided argument is a valid JSON.
|
Checks if the provided argument is a valid JSON.
|
||||||
|
|
||||||
Use `JSON.parse()` and a `try... catch` block to check if the provided argument is a valid JSON.
|
Use `JSON.parse()` and a `try... catch` block to check if the provided argument is a valid JSON and non-null.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const isValidJSON = obj => {
|
const isValidJSON = obj => {
|
||||||
try {
|
try {
|
||||||
JSON.parse(obj);
|
JSON.parse(obj);
|
||||||
return true;
|
return !!obj;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@ Returns `true` if the given string is an absolute URL, `false` otherwise.
|
|||||||
Use a regular expression to test if the string is an absolute URL.
|
Use a regular expression to test if the string is an absolute URL.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);
|
const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const isValidJSON = obj => {
|
|||||||
try {
|
try {
|
||||||
JSON.parse(obj);
|
JSON.parse(obj);
|
||||||
return !!obj;
|
return !!obj;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user