Disable the validation badge for those who do not want it (#5994)
* disabled on string values: "127.0.0.1", "localhost", "none"
This commit is contained in:
@@ -2,7 +2,7 @@ import React from "react"
|
||||
import URL from "url-parse"
|
||||
|
||||
import PropTypes from "prop-types"
|
||||
import { sanitizeUrl } from "core/utils"
|
||||
import { sanitizeUrl, requiresValidationURL } from "core/utils"
|
||||
import win from "core/window"
|
||||
|
||||
export default class OnlineValidatorBadge extends React.Component {
|
||||
@@ -48,8 +48,8 @@ export default class OnlineValidatorBadge extends React.Component {
|
||||
|
||||
if ( typeof spec === "object" && Object.keys(spec).length) return null
|
||||
|
||||
if (!this.state.url || !this.state.validatorUrl || this.state.url.indexOf("localhost") >= 0
|
||||
|| this.state.url.indexOf("127.0.0.1") >= 0) {
|
||||
if (!this.state.url || !requiresValidationURL(this.state.validatorUrl)
|
||||
|| !requiresValidationURL(this.state.url)) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -800,6 +800,15 @@ export function sanitizeUrl(url) {
|
||||
return braintreeSanitizeUrl(url)
|
||||
}
|
||||
|
||||
|
||||
export function requiresValidationURL(uri) {
|
||||
if (!uri || uri.indexOf("localhost") >= 0 || uri.indexOf("127.0.0.1") >= 0 || uri === "none") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
export function getAcceptControllingResponse(responses) {
|
||||
if(!Im.OrderedMap.isOrderedMap(responses)) {
|
||||
// wrong type!
|
||||
|
||||
Reference in New Issue
Block a user