isSlug.js 212 B

123456
  1. import assertString from './util/assertString';
  2. var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/;
  3. export default function isSlug(str) {
  4. assertString(str);
  5. return charsetRegex.test(str);
  6. }