Skip to content

Commit

Permalink
Finish up next release (#74)
Browse files Browse the repository at this point in the history
* Update documentation

* Add matchHostnames alias for matchDomains #73

* Remove debug log

* Handle file urls, bump version
  • Loading branch information
johnste committed Aug 21, 2019
1 parent 632689d commit 14ffb52
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 33 deletions.
1 change: 0 additions & 1 deletion Finicky/Finicky/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele

func performTest(url: URL) {
if let appDescriptor = configLoader.determineOpeningApp(url: url, sourceBundleIdentifier: "net.kassett.finicky") {
print(appDescriptor)
var description = """
Would open url: \(appDescriptor.url)
Expand Down
2 changes: 1 addition & 1 deletion Finicky/Finicky/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ open class FinickyConfig {
defaultBrowser: "Safari",
handlers: [
{
match: finicky.matchDomains(["youtube.com", "facebook.com"]),
match: finicky.matchHostnames(["youtube.com", "facebook.com"]),
browser: "Google Chrome"
}
]
Expand Down
4 changes: 2 additions & 2 deletions Finicky/Finicky/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>v2.2.0</string>
<string>v2.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -67,7 +67,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>158</string>
<string>160</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
7 changes: 4 additions & 3 deletions Finicky/Finicky/finickyConfigAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ var finickyConfigApi = (function (exports) {
url: validate.oneOf([
validate.string,
validate.shape({
protocol: validate.oneOf(["http", "https"]).isRequired,
protocol: validate.oneOf(["http", "https", "file"]).isRequired,
username: validate.string,
password: validate.string,
host: validate.string.isRequired,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ var finickyConfigApi = (function (exports) {
args[_i - 1] = arguments[_i];
}
if (args.length > 0) {
throw new Error("finicky.matchDomains(domains) only accepts one argument. See https://johnste.github.io/finicky-docs/interfaces/_finickyapi_.finicky.html#matchdomains for more information");
throw new Error("finicky.matchDomains/matchHostnames only accepts one argument. See https://johnste.github.io/finicky-docs/interfaces/_finickyapi_.finicky.html#matchdomains for more information");
}
if (!Array.isArray(matchers)) {
matchers = [matchers];
Expand All @@ -1080,7 +1080,7 @@ var finickyConfigApi = (function (exports) {
if (matcher instanceof RegExp || typeof matcher === "string") {
return;
}
throw new Error("finicky.matchDomains(domains): Unrecognized domain \"" + matcher + "\"");
throw new Error("finicky.matchDomains/matchHostnames: Unrecognized hostname \"" + matcher + "\"");
});
return function (_a) {
var url = _a.url;
Expand Down Expand Up @@ -1109,6 +1109,7 @@ var finickyConfigApi = (function (exports) {
log: log,
notify: notify,
matchDomains: matchDomains,
matchHostnames: matchDomains,
getUrlParts: getUrlParts,
onUrl: onUrl,
setDefaultBrowser: setDefaultBrowser
Expand Down
63 changes: 44 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

</div>

Finicky is an macOS application that allows you to set up rules that decide which browser is opened for every link or url. With Finicky as your default browser, you can tell it to open Facebook or Reddit in one browser, and Trello or LinkedIn in another.
Finicky is an macOS application that allows you to set up rules that decide which browser is opened for every link or url. With Finicky as your default browser, you can tell it to open Facebook or Reddit in one browser, and Trello or LinkedIn in another.

- Write rules to open urls in any browser
- Rewrite and replace parts of urls before opening them
Expand All @@ -29,11 +29,11 @@ Finicky is an macOS application that allows you to set up rules that decide whic
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Installation](#installation)
- [Example configuration](#example-configuration)
- [Basic configuration](#basic-configuration)
- [Wildcard matching](#wildcard-matching)
- [Opening preferred browser](#opening-preferred-browser)
- [Rewrite urls](#rewrite-urls)
- [Advanced usage, settings](#advanced-usage-settings)
- [Keyboard modifiers](#keyboard-modifiers)
Expand Down Expand Up @@ -68,15 +68,18 @@ Finicky is an macOS application that allows you to set up rules that decide whic
```js
module.exports = {
defaultBrowser: "Google Chrome",
handlers: [{
// Open apple.com and example.org urls in Safari
match: finicky.matchDomains(["apple.com", "example.org"]),
browser: "Safari"
}, {
// Open any url including the string "workplace" in Firefox
match: /workplace/,
browser: "Firefox"
}]
handlers: [
{
// Open apple.com and example.org urls in Safari
match: finicky.matchHostnames(["apple.com", "example.org"]),
browser: "Safari"
},
{
// Open any url including the string "workplace" in Firefox
match: /workplace/,
browser: "Firefox"
}
]
};
```

Expand All @@ -85,14 +88,31 @@ module.exports = {
```js
module.exports = {
defaultBrowser: "Safari",
handlers: [{
// Open google.com and *.google.com urls in Google Chrome
match: finicky.matchDomains([
"google.com", // match google.com domain as string (to make regular expression less complicated)
/.*\.google.com$/ // match all google.com subdomains
]),
browser: "Google Chrome"
}]
handlers: [
{
// Open google.com and *.google.com urls in Google Chrome
match: finicky.matchHostnames([
"google.com", // match google.com domain as string (to make regular expression less complicated)
/.*\.google.com$/ // match all google.com subdomains
]),
browser: "Google Chrome"
}
]
};
```

### Opening preferred browser

```js
module.exports = {
defaultBrowser: "Safari",
handlers: [
{
match: finicky.matchHostnames(["example.com"]),
// Opens the first running browsers in the list. If none are running, the first one will be started.
browser: ["Google Chrome", "Safari", "Firefox"]
}
]
};
```

Expand Down Expand Up @@ -145,6 +165,11 @@ module.exports = {
// Force opening the link in the background
openInBackground: true
}
},
{
match: ["http://example.com"],
// Don't open any browser for this url, effectively blocking it
browser: null
}
]
};
Expand Down
4 changes: 2 additions & 2 deletions config-api/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const url = args[0] || "https://example.com/test";

const protocol = urlParse(url).protocol.replace(":", "");

if (protocol !== "http" && protocol !== "https") {
if (protocol !== "http" && protocol !== "https" && protocol !== "file") {
errorMessage(
chalk`Finicky only processes {underline http and https} urls. Supplied url has protocol:`,
chalk`Finicky only processes {underline file, http and https} urls. Supplied url has protocol:`,
protocol
);
process.exit(1);
Expand Down
5 changes: 3 additions & 2 deletions config-api/src/createAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function createAPI(
const matchDomains = (matchers: Matcher | Matcher[], ...args: any[]) => {
if (args.length > 0) {
throw new Error(
"finicky.matchDomains(domains) only accepts one argument. See https://johnste.github.io/finicky-docs/interfaces/_finickyapi_.finicky.html#matchdomains for more information"
"finicky.matchDomains/matchHostnames only accepts one argument. See https://johnste.github.io/finicky-docs/interfaces/_finickyapi_.finicky.html#matchdomains for more information"
);
}

Expand All @@ -71,7 +71,7 @@ export function createAPI(
return;
}
throw new Error(
`finicky.matchDomains(domains): Unrecognized domain "${matcher}"`
`finicky.matchDomains/matchHostnames: Unrecognized hostname "${matcher}"`
);
});

Expand Down Expand Up @@ -114,6 +114,7 @@ export function createAPI(
log,
notify,
matchDomains,
matchHostnames: matchDomains,
getUrlParts,
onUrl,
setDefaultBrowser
Expand Down
3 changes: 2 additions & 1 deletion config-api/src/processUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ declare const module:
| undefined;

declare const finicky: {
matchDomains(domains: string | string[]): boolean;
matchDomains(hostnames: string | string[]): boolean;
matchHostnames(hostnames: string | string[]): boolean;
log(value: string): void;
notify(title: string, subtitle?: string): void;
getUrlParts(url: string): UrlObject;
Expand Down
4 changes: 2 additions & 2 deletions config-api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { validate } from "./fastidious/index";
* hideIcon: false
* },
* handlers: [{
* match: finicky.matchDomains("example.com'),
* match: finicky.matchHostnames("example.com'),
* browser: "Firefox"
* }]
* }
Expand Down Expand Up @@ -157,7 +157,7 @@ export const urlSchema = {
url: validate.oneOf([
validate.string,
validate.shape({
protocol: validate.oneOf(["http", "https"]).isRequired,
protocol: validate.oneOf(["http", "https", "file"]).isRequired,
username: validate.string,
password: validate.string,
host: validate.string.isRequired,
Expand Down

0 comments on commit 14ffb52

Please sign in to comment.