github-url-from-username-repo
Advanced tools
Comparing version 1.0.0 to 1.0.1
11
index.js
@@ -5,3 +5,12 @@ module.exports = getUrl | ||
if (!r) return null | ||
if (/^[\w-]+\/[\w\.-]+(#[a-z0-9]*)?$/.test(r)) { | ||
// Regex taken from https://github.com/npm/npm-package-arg/commit/01dce583c64afae07b66a2a8a6033aeba871c3cd | ||
// Note: This does not fully test the git ref format. | ||
// See https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html | ||
// | ||
// The only way to do this properly would be to shell out to | ||
// git-check-ref-format, and as this is a fast sync function, | ||
// we don't want to do that. Just let git fail if it turns | ||
// out that the commit-ish is invalid. | ||
// GH usernames cannot start with . or - | ||
if (/^[^@%\/\s\.-][^@%\/\s]*\/[^@\s\/%]+(?:#.*)?$/.test(r)) { | ||
if (forBrowser) | ||
@@ -8,0 +17,0 @@ r = r.replace("#", "/tree/") |
{ | ||
"name": "github-url-from-username-repo", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Create urls from username/repo", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,3 +42,10 @@ var assert = require("assert") | ||
}) | ||
it("can handle branches with slashes", function () { | ||
var url = getUrl( | ||
"component/entejs#some/branch/name") | ||
assert.equal("https://github.com/component/entejs#some/branch/name", url) | ||
}) | ||
describe("browser mode", function () { | ||
@@ -45,0 +52,0 @@ it("is able to return urls for branches", function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5567
71