-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for vanity URLs (#1017)
Signed-off-by: Ian Lewis <[email protected]>
- Loading branch information
Ian Lewis
authored
Nov 9, 2023
1 parent
3c12e3f
commit a1c5d2d
Showing
13 changed files
with
8,846 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import * as fs from "fs"; | ||
import * as os from "os"; | ||
import * as path from "path"; | ||
|
||
import YAML from "yaml"; | ||
|
||
import * as config from "../src/config"; | ||
|
||
describe("readConfig", () => { | ||
it("handles non-existant config", async () => { | ||
let c = await config.readConfig("not-exists.yml"); | ||
expect(c).toEqual({}); | ||
}); | ||
|
||
it("handles empty config", async () => { | ||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "readConfig")); | ||
const configPath = path.join(tmpDir, "empty.yml"); | ||
fs.writeFileSync(configPath, ""); | ||
|
||
let c = await config.readConfig(configPath); | ||
|
||
expect(c).toEqual({}); | ||
}); | ||
|
||
it("handles basic config", async () => { | ||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "readConfig")); | ||
const configPath = path.join(tmpDir, "todos.yml"); | ||
fs.writeFileSync( | ||
configPath, | ||
'vanityURLs:\n - "(https?://)?golang.org/issues/(?<id>[0-9]+)"', | ||
); | ||
|
||
let c = await config.readConfig(configPath); | ||
|
||
expect(c).toEqual({ | ||
vanityURLs: ["(https?://)?golang.org/issues/(?<id>[0-9]+)"], | ||
}); | ||
}); | ||
|
||
it("handles invalid config", async () => { | ||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "readConfig")); | ||
const configPath = path.join(tmpDir, "todos.yml"); | ||
fs.writeFileSync(configPath, "vanityURLs:\n- ,"); | ||
|
||
expect(() => config.readConfig(configPath)).rejects.toThrow( | ||
YAML.YAMLParseError, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.