版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 1 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # unc-path-regex [![NPM version](https://badge.fury.io/js/unc-path-regex.svg)](http://badge.fury.io/js/unc-path-regex) [![Build Status](https://travis-ci.org/jonschlinkert/unc-path-regex.svg)](https://travis-ci.org/jonschlinkert/unc-path-regex)
  2. > Regular expression for testing if a file path is a windows UNC file path. Can also be used as a component of another regexp via the `.source` property.
  3. Visit the MSDN reference for [Common Data Types 2.2.57 UNC](https://msdn.microsoft.com/en-us/library/gg465305.aspx) for more information about UNC paths.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/)
  6. ```sh
  7. $ npm i unc-path-regex --save
  8. ```
  9. ## Usage
  10. ```js
  11. // unc-path-regex returns a function
  12. var regex = require('unc-path-regex')();
  13. ```
  14. **true**
  15. Returns true for windows UNC paths:
  16. ```js
  17. regex.test('\\/foo/bar');
  18. regex.test('\\\\foo/bar');
  19. regex.test('\\\\foo\\admin$');
  20. regex.test('\\\\foo\\admin$\\system32');
  21. regex.test('\\\\foo\\temp');
  22. regex.test('\\\\/foo/bar');
  23. regex.test('\\\\\\/foo/bar');
  24. ```
  25. **false**
  26. Returns false for non-UNC paths:
  27. ```js
  28. regex.test('/foo/bar');
  29. regex.test('/');
  30. regex.test('/foo');
  31. regex.test('/foo/');
  32. regex.test('c:');
  33. regex.test('c:.');
  34. regex.test('c:./');
  35. regex.test('c:./file');
  36. regex.test('c:/');
  37. regex.test('c:/file');
  38. ```
  39. ## Related projects
  40. * [dotfile-regex](https://github.com/regexps/dotfile-regex): Regular expresson for matching dotfiles.
  41. * [dotdir-regex](https://github.com/regexps/dotdir-regex): Regex for matching dot-directories, like `.git/`
  42. * [dirname-regex](https://github.com/regexps/dirname-regex): Regular expression for matching the directory part of a file path.
  43. * [is-unc-path](https://github.com/jonschlinkert/is-unc-path): Returns true if a filepath is a windows UNC file path.
  44. * [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern.
  45. * [path-regex](https://github.com/regexps/path-regex): Regular expression for matching the parts of a file path.
  46. ## Running tests
  47. Install dev dependencies:
  48. ```sh
  49. $ npm i -d && npm test
  50. ```
  51. ## Contributing
  52. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/unc-path-regex/issues/new)
  53. ## Author
  54. **Jon Schlinkert**
  55. + [github/jonschlinkert](https://github.com/jonschlinkert)
  56. + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  57. ## License
  58. Copyright © 2015 Jon Schlinkert
  59. Released under the MIT license.
  60. ***
  61. _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 07, 2015._