Blame view

src/utils/validate.js 357 Bytes
406803045 committed
1
/**
406803045 committed
2
 * Created by Sunnie on 19/06/04.
406803045 committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}