mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
improve url regex
This commit is contained in:
@@ -141,7 +141,6 @@ describe("test path validation", () => {
|
|||||||
|
|
||||||
describe("test url validation", () => {
|
describe("test url validation", () => {
|
||||||
const invalid = [
|
const invalid = [
|
||||||
"file:///blah/index.html",
|
|
||||||
"http://",
|
"http://",
|
||||||
"http://.",
|
"http://.",
|
||||||
"http://..",
|
"http://..",
|
||||||
@@ -158,12 +157,9 @@ describe("test url validation", () => {
|
|||||||
"///a",
|
"///a",
|
||||||
"///",
|
"///",
|
||||||
"foo.com",
|
"foo.com",
|
||||||
"rdar://1234",
|
|
||||||
"h://test",
|
|
||||||
"http:// shouldfail.com",
|
"http:// shouldfail.com",
|
||||||
":// should fail",
|
":// should fail",
|
||||||
"http://foo.bar/foo(bar)baz quux",
|
"http://foo.bar/foo(bar)baz quux",
|
||||||
"ftps://foo.bar/",
|
|
||||||
"http://.www.foo.bar/",
|
"http://.www.foo.bar/",
|
||||||
"http://.www.foo.bar./"
|
"http://.www.foo.bar./"
|
||||||
];
|
];
|
||||||
@@ -173,9 +169,12 @@ describe("test url validation", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
const valid = [
|
const valid = [
|
||||||
|
"ftps://foo.bar/",
|
||||||
|
"h://test",
|
||||||
|
"rdar://1234",
|
||||||
|
"file:///blah/index.html",
|
||||||
"https://foo.com/blah_blah",
|
"https://foo.com/blah_blah",
|
||||||
"ssh://foo.com/blah_blah",
|
"ssh://foo.com/blah_blah",
|
||||||
"ftp://foo.com/blah_blah",
|
|
||||||
"https://foo.com/blah_blah/",
|
"https://foo.com/blah_blah/",
|
||||||
"https://foo.com/blah_blah_(wikipedia)",
|
"https://foo.com/blah_blah_(wikipedia)",
|
||||||
"https://foo.com/blah_blah_(wikipedia)_(again)",
|
"https://foo.com/blah_blah_(wikipedia)_(again)",
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const isPathValid = (path: string) => {
|
|||||||
return pathRegex.test(path);
|
return pathRegex.test(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
const urlRegex = /^(ssh|ftp|https?):\/\/[^\s$.?#].[^\s]*$/;
|
const urlRegex = /^[A-Za-z0-9]+:\/\/[^\s$.?#].[^\s]*$/;
|
||||||
|
|
||||||
export const isUrlValid = (url: string) => {
|
export const isUrlValid = (url: string) => {
|
||||||
return urlRegex.test(url);
|
return urlRegex.test(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user