Skip to content

Commit 6fb1562

Browse files
committed
first commit
0 parents  commit 6fb1562

11 files changed

+343
-0
lines changed

.editorconfig

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
end_of_line = lf
7+
charset = utf-8
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
insert_final_newline = false
15+
16+
[{,test/}{actual,fixtures}/**]
17+
trim_trailing_whitespace = false
18+
insert_final_newline = false
19+
20+
[templates/**]
21+
trim_trailing_whitespace = false
22+
insert_final_newline = false

.gitattributes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Enforce Unix newlines
2+
* text eol=lf
3+
4+
# binaries
5+
*.ai binary
6+
*.psd binary
7+
*.jpg binary
8+
*.gif binary
9+
*.png binary
10+
*.jpeg binary

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.DS_Store
2+
*.sublime-*
3+
_gh_pages
4+
bower_components
5+
node_modules
6+
npm-debug.log
7+
actual
8+
test/actual
9+
temp
10+
tmp
11+
TODO.md
12+
vendor
13+
.idea
14+
benchmark
15+
coverage

.jshintrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"asi": false,
3+
"boss": true,
4+
"curly": true,
5+
"eqeqeq": true,
6+
"eqnull": true,
7+
"esnext": true,
8+
"immed": true,
9+
"latedef": false,
10+
"laxcomma": false,
11+
"mocha": true,
12+
"newcap": true,
13+
"noarg": true,
14+
"node": true,
15+
"sub": true,
16+
"undef": true,
17+
"unused": true
18+
}

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "0.10"
5+
- "0.12"
6+
- "0.13"
7+
- "iojs"
8+
matrix:
9+
fast_finish: true
10+
allow_failures:
11+
- node_js: "0.13"

.verb.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# {%= name %} {%= badge("fury") %}
2+
3+
> {%= description %}
4+
5+
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.
6+
7+
## Install
8+
{%= include("install-npm", {save: true}) %}
9+
10+
## Usage
11+
12+
```js
13+
// unc-path-regex returns a function
14+
var regex = require('{%= name %}')();
15+
```
16+
17+
**true**
18+
19+
Returns true for windows UNC paths:
20+
21+
```js
22+
regex.test('\\/foo/bar');
23+
regex.test('\\\\foo/bar');
24+
regex.test('\\\\foo\\admin$');
25+
regex.test('\\\\foo\\admin$\\system32');
26+
regex.test('\\\\foo\\temp');
27+
regex.test('\\\\/foo/bar');
28+
regex.test('\\\\\\/foo/bar');
29+
```
30+
31+
**false**
32+
33+
Returns false for non-UNC paths:
34+
35+
```js
36+
regex.test('/foo/bar');
37+
regex.test('/');
38+
regex.test('/foo');
39+
regex.test('/foo/');
40+
regex.test('c:');
41+
regex.test('c:.');
42+
regex.test('c:./');
43+
regex.test('c:./file');
44+
regex.test('c:/');
45+
regex.test('c:/file');
46+
```
47+
48+
## Related projects
49+
{%= related(verb.related.list, {remove: name}) %}
50+
51+
## Running tests
52+
{%= include("tests") %}
53+
54+
## Contributing
55+
{%= include("contributing") %}
56+
57+
## Author
58+
{%= include("author") %}
59+
60+
## License
61+
{%= copyright() %}
62+
{%= license() %}
63+
64+
***
65+
66+
{%= include("footer") %}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015, Jon Schlinkert.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# unc-path-regex [![NPM version](https://badge.fury.io/js/unc-path-regex.svg)](http://badge.fury.io/js/unc-path-regex)
2+
3+
> 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.
4+
5+
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.
6+
7+
## Install
8+
9+
Install with [npm](https://www.npmjs.com/)
10+
11+
```sh
12+
$ npm i unc-path-regex --save
13+
```
14+
15+
## Usage
16+
17+
```js
18+
// unc-path-regex returns a function
19+
var regex = require('unc-path-regex')();
20+
```
21+
22+
**true**
23+
24+
Returns true for windows UNC paths:
25+
26+
```js
27+
regex.test('\\/foo/bar');
28+
regex.test('\\\\foo/bar');
29+
regex.test('\\\\foo\\admin$');
30+
regex.test('\\\\foo\\admin$\\system32');
31+
regex.test('\\\\foo\\temp');
32+
regex.test('\\\\/foo/bar');
33+
regex.test('\\\\\\/foo/bar');
34+
```
35+
36+
**false**
37+
38+
Returns false for non-UNC paths:
39+
40+
```js
41+
regex.test('/foo/bar');
42+
regex.test('/');
43+
regex.test('/foo');
44+
regex.test('/foo/');
45+
regex.test('c:');
46+
regex.test('c:.');
47+
regex.test('c:./');
48+
regex.test('c:./file');
49+
regex.test('c:/');
50+
regex.test('c:/file');
51+
```
52+
53+
## Related projects
54+
55+
* [dotfile-regex](https://github.com/regexps/dotfile-regex): Regular expresson for matching dotfiles.
56+
* [dotdir-regex](https://github.com/regexps/dotdir-regex): Regex for matching dot-directories, like `.git/`
57+
* [dirname-regex](https://github.com/regexps/dirname-regex): Regular expression for matching the directory part of a file path.
58+
* [is-unc-path](https://github.com/jonschlinkert/is-unc-path): Returns true if a filepath is a windows UNC file path.
59+
* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern.
60+
* [path-regex](https://github.com/regexps/path-regex): Regular expression for matching the parts of a file path.
61+
62+
## Running tests
63+
64+
Install dev dependencies:
65+
66+
```sh
67+
$ npm i -d && npm test
68+
```
69+
70+
## Contributing
71+
72+
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)
73+
74+
## Author
75+
76+
**Jon Schlinkert**
77+
78+
+ [github/jonschlinkert](https://github.com/jonschlinkert)
79+
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
80+
81+
## License
82+
83+
Copyright © 2015 Jon Schlinkert
84+
Released under the MIT license.
85+
86+
***
87+
88+
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 07, 2015._

index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = function uncPathRegex() {
4+
return /^[\\\/]{2,}[^\\\/]+[\\\/]+[^\\\/]+/;
5+
};

package.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "unc-path-regex",
3+
"description": "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.",
4+
"version": "0.1.1",
5+
"homepage": "https://github.com/jonschlinkert/unc-path-regex",
6+
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7+
"repository": "jonschlinkert/unc-path-regex",
8+
"bugs": {
9+
"url": "https://github.com/jonschlinkert/unc-path-regex/issues"
10+
},
11+
"license": "MIT",
12+
"files": [
13+
"index.js"
14+
],
15+
"main": "index.js",
16+
"engines": {
17+
"node": ">=0.10.0"
18+
},
19+
"scripts": {
20+
"test": "mocha"
21+
},
22+
"devDependencies": {
23+
"mocha": "*"
24+
},
25+
"keywords": [
26+
"absolute",
27+
"expression",
28+
"file",
29+
"filepath",
30+
"match",
31+
"matching",
32+
"path",
33+
"regex",
34+
"regexp",
35+
"regular",
36+
"unc",
37+
"win",
38+
"windows"
39+
],
40+
"verb": {
41+
"related": {
42+
"list": [
43+
"dotfile-regex",
44+
"is-unc-path",
45+
"unc-path-regex",
46+
"dotdir-regex",
47+
"path-regex",
48+
"dirname-regex",
49+
"is-glob"
50+
]
51+
}
52+
}
53+
}

test.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
/* deps:mocha */
4+
var assert = require('assert');
5+
var regex = require('./');
6+
7+
function unc(str) {
8+
return regex().test(str);
9+
}
10+
11+
describe('UNC path regex', function () {
12+
it('should return true for UNC paths', function () {
13+
assert.equal(unc('\\/foo/bar'), true);
14+
assert.equal(unc('\\\\foo/bar'), true);
15+
assert.equal(unc('\\\\foo\\admin$'), true);
16+
assert.equal(unc('\\\\foo\\admin$\\system32'), true);
17+
assert.equal(unc('\\\\foo\\temp'), true);
18+
assert.equal(unc('\\\\/foo/bar'), true);
19+
assert.equal(unc('\\\\\\/foo/bar'), true);
20+
});
21+
22+
it('should return false for non-UNC paths', function () {
23+
assert.equal(unc('/foo/bar'), false);
24+
assert.equal(unc('/'), false);
25+
assert.equal(unc('/foo'), false);
26+
assert.equal(unc('/foo/'), false);
27+
assert.equal(unc('c:'), false);
28+
assert.equal(unc('c:.'), false);
29+
assert.equal(unc('c:./'), false);
30+
assert.equal(unc('c:./file'), false);
31+
assert.equal(unc('c:/'), false);
32+
assert.equal(unc('c:/file'), false);
33+
});
34+
});

0 commit comments

Comments
 (0)