• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vuepress / vuepress-next / 3860787019

pending completion
3860787019

Pull #1230

github

GitHub
Merge a55297b33 into b4e313bb7
Pull Request #1230: feat: add helper package

325 of 478 branches covered (67.99%)

Branch coverage included in aggregate %.

8 of 8 new or added lines in 2 files covered. (100.0%)

685 of 1011 relevant lines covered (67.75%)

42.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.14
/packages/shared/src/utils/isUrl.ts
1
// eslint-disable-next-line vue/prefer-import-from-vue
2
import { isString } from '@vue/shared'
3

4
/**
5
 * check if a variable is a valid url
6
 */
7
export const isUrl = (test: unknown): boolean => {
51✔
8
  if (!isString(test) || test === '') return false
×
9

10
  // url Math
11
  const result = /^(?:\w+:)?\/\/(\S+)$/u.exec(test)
×
12

13
  const address = result?.[1]
×
14

15
  if (!address) return false
×
16

17
  return (
×
18
    // address with localhost
19
    /^localhost[:?\d]*(?:[^:?\d]\S*)?$/u.test(address) ||
×
20
    // address without localhost
21
    /^[^\s.]+\.\S{2,}$/u.test(address)
22
  )
23
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc