Skip to content

Commit

Permalink
Updated regular expression to identify a url
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Oct 4, 2018
1 parent ac85017 commit b68640d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/tests/unit/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export const validUrls = [
"google.com/search/?query=google-something&param=value",
"https://www.google.com/search/?query=google-something&param=value",
"www.google.com/search/?query=google-something&param=value",
"google.com",
"https://google.com",
"http://google.com",
"//google.com",
"google.com?query=sdf",
"google.com?query=asdf&shit=true",
"mail.google.com",
"https://www.example.com:8080/index.html?p1=A&p2=B#ressource",
];

export const invalidUrls = [
Expand All @@ -68,6 +76,16 @@ export const invalidUrls = [
"some-bullshit",
"12340.12",
"darth.vader@empire.cc",
"invalid",
"bullshit",
"gooogle.",
"google.c",
"http:/google.com",
"http//google.com",
"http://goooglecom",
"someone@mail.com",
"http://.com",
"ftp://google.com",
];

export const dummyWebSearches = [
Expand Down
2 changes: 1 addition & 1 deletion src/ts/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IconSet } from "./icon-sets/icon-set";

export class Injector {
public static getWebUrlRegExp(): RegExp {
return new RegExp(/^((https?:)?[/]{2})?([a-z0-9]+[.])+[a-z]+.*$/i, "gi");
return new RegExp(/^((https?:)?[/]{2})?([a-z0-9]+[.])+[a-z]{2,}.*$/i, "gi");
}

public static getOpenUrlWithDefaultBrowserCommand(platform: string, url: string): string {
Expand Down

0 comments on commit b68640d

Please sign in to comment.