pax_global_header00006660000000000000000000000064127020320000014474gustar00rootroot0000000000000052 comment=59553801a9f389857b48e71e9ab54592815f7d15 normalize-git-url-3.0.2/000077500000000000000000000000001270203200000150575ustar00rootroot00000000000000normalize-git-url-3.0.2/.eslintrc000066400000000000000000000006371270203200000167110ustar00rootroot00000000000000{ "env" : { "node" : true }, "rules" : { "semi": [2, "never"], "strict": 0, "quotes": [1, "double", "avoid-escape"], "no-use-before-define": 0, "curly": 0, "no-underscore-dangle": 0, "no-lonely-if": 1, "no-unused-vars": [2, {"vars" : "all", "args" : "after-used"}], "no-mixed-requires": 0, "space-infix-ops": 0, "key-spacing": 0, "no-multi-spaces": 0 } } normalize-git-url-3.0.2/.gitignore000066400000000000000000000000161270203200000170440ustar00rootroot00000000000000node_modules/ normalize-git-url-3.0.2/.travis.yml000066400000000000000000000001631270203200000171700ustar00rootroot00000000000000language: node_js node_js: - "5" - "4" - iojs - "0.12" - "0.10" - "0.8" sudo: false script: "npm test" normalize-git-url-3.0.2/CHANGELOG.md000066400000000000000000000003241270203200000166670ustar00rootroot00000000000000### 1.0.0 (2014-12-25): * [`8b3d874`](https://github.com/npm/normalize-git-url/commit/8b3d874afd14f4cdde65d418e0a35a615c746bba) Initial version, with simple tests. ([@othiym23](https://github.com/othiym23)) normalize-git-url-3.0.2/LICENSE000066400000000000000000000013451270203200000160670ustar00rootroot00000000000000Copyright (c) 2014-2015, Forrest L Norvell Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. normalize-git-url-3.0.2/README.md000066400000000000000000000025331270203200000163410ustar00rootroot00000000000000# normalize-git-url You have a bunch of Git URLs. You want to convert them to a canonical representation, probably for use inside npm so that it doesn't end up creating a bunch of superfluous cached origins. You use this package. ## Usage ```javascript var ngu = require('normalize-git-url'); var normalized = ngu("git+ssh://git@github.com:organization/repo.git#hashbrowns") // get back: // { // url : "ssh://git@github.com/organization/repo.git", // branch : "hashbrowns" // did u know hashbrowns are delicious? // } ``` ## API There's just the one function, and all it takes is a single parameter, a non-normalized Git URL. ### normalizeGitUrl(url) * `url` {String} The Git URL (very loosely speaking) to be normalized. Returns an object with the following format: * `url` {String} The normalized URL. * `branch` {String} The treeish to be checked out once the repo at `url` is cloned. It doesn't have to be a branch, but it's a lot easier to intuit what the output is for with that name. ## Limitations Right now this doesn't try to special-case GitHub too much -- it doesn't ensure that `.git` is added to the end of URLs, it doesn't prefer `https:` over `http:` or `ssh:`, it doesn't deal with redirects, and it doesn't try to resolve symbolic names to treeish hashcodes. For now, it just tries to account for minor differences in representation. normalize-git-url-3.0.2/normalize-git-url.js000066400000000000000000000022271270203200000210010ustar00rootroot00000000000000var url = require('url') module.exports = function normalize (u) { var parsed = url.parse(u) // If parsing actually alters the URL, it is almost certainly an // scp-style URL, or an invalid one. var altered = u !== url.format(parsed) // git is so tricky! // if the path is like ssh://foo:22/some/path then it works, but // it needs the ssh:// // If the path is like ssh://foo:some/path then it works, but // only if you remove the ssh:// if (parsed.protocol) { parsed.protocol = parsed.protocol.replace(/^git\+/, '') } // figure out what we should check out. var checkout = parsed.hash && parsed.hash.substr(1) || 'master' parsed.hash = '' var returnedUrl if (altered) { if (u.match(/^git\+https?/) && parsed.pathname.match(/\/?:[^0-9]/)) { returnedUrl = u.replace(/^git\+(.*:[^:]+):(.*)/, '$1/$2') } else if (u.match(/^git\+file/)) { returnedUrl = u.replace(/^git\+/, '') } else { returnedUrl = u.replace(/^(?:git\+)?ssh:\/\//, '') } returnedUrl = returnedUrl.replace(/#[^#]*$/, '') } else { returnedUrl = url.format(parsed) } return { url: returnedUrl, branch: checkout } } normalize-git-url-3.0.2/package.json000066400000000000000000000013171270203200000173470ustar00rootroot00000000000000{ "name": "normalize-git-url", "version": "3.0.2", "description": "Normalizes Git URLs. For npm, but you can use it too.", "main": "normalize-git-url.js", "directories": { "test": "test" }, "dependencies": {}, "devDependencies": { "tap": "^1.1.0" }, "scripts": { "test": "tap test/*.js" }, "repository": { "type": "git", "url": "https://github.com/npm/normalize-git-url.git" }, "keywords": [ "git", "github", "url", "normalize", "npm" ], "author": "Forrest L Norvell ", "license": "ISC", "bugs": { "url": "https://github.com/npm/normalize-git-url/issues" }, "homepage": "https://github.com/npm/normalize-git-url" } normalize-git-url-3.0.2/test/000077500000000000000000000000001270203200000160365ustar00rootroot00000000000000normalize-git-url-3.0.2/test/basic.js000066400000000000000000000046621270203200000174650ustar00rootroot00000000000000var test = require('tap').test var normalize = require('../normalize-git-url.js') test('basic normalization tests', function (t) { t.same( normalize('git+ssh://user@hostname:project.git#commit-ish'), { url: 'user@hostname:project.git', branch: 'commit-ish' } ) t.same( normalize('git+http://user@hostname/project/blah.git#commit-ish'), { url: 'http://user@hostname/project/blah.git', branch: 'commit-ish' } ) t.same( normalize('git+https://user@hostname/project/blah.git#commit-ish'), { url: 'https://user@hostname/project/blah.git', branch: 'commit-ish' } ) t.same( normalize('git+https://user@hostname:project/blah.git#commit-ish'), { url: 'https://user@hostname/project/blah.git', branch: 'commit-ish' } ) t.same( normalize('git+ssh://git@github.com:npm/npm.git#v1.0.27'), { url: 'git@github.com:npm/npm.git', branch: 'v1.0.27' } ) t.same( normalize('git+ssh://git@github.com:/npm/npm.git#v1.0.28'), { url: 'git@github.com:/npm/npm.git', branch: 'v1.0.28' } ) t.same( normalize('git+ssh://git@github.com:org/repo#dev'), { url: 'git@github.com:org/repo', branch: 'dev' } ) t.same( normalize('git+ssh://git@github.com/org/repo#dev'), { url: 'ssh://git@github.com/org/repo', branch: 'dev' } ) t.same( normalize('git+ssh://foo:22/some/path'), { url: 'ssh://foo:22/some/path', branch: 'master' } ) t.same( normalize('git@github.com:org/repo#dev'), { url: 'git@github.com:org/repo', branch: 'dev' } ) t.same( normalize('git+https://github.com/KenanY/node-uuid'), { url: 'https://github.com/KenanY/node-uuid', branch: 'master' } ) t.same( normalize('git+https://github.com/KenanY/node-uuid#7a018f2d075b03a73409e8356f9b29c9ad4ea2c5'), { url: 'https://github.com/KenanY/node-uuid', branch: '7a018f2d075b03a73409e8356f9b29c9ad4ea2c5' } ) t.same( normalize('git+ssh://git@git.example.com:b/b.git#v1.0.0'), { url: 'git@git.example.com:b/b.git', branch: 'v1.0.0' } ) t.same( normalize('git+ssh://git@github.com:npm/npm-proto.git#othiym23/organized'), { url: 'git@github.com:npm/npm-proto.git', branch: 'othiym23/organized' } ) t.same( normalize('git+file:///foo/bar.git'), { url: 'file:///foo/bar.git', branch: 'master' } ) t.same( normalize('git+file://C:\\Users\\hello\\testing.git#zkat/windows-files'), { url: 'file://C:\\Users\\hello\\testing.git', branch: 'zkat/windows-files'} ) t.end() })