-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MediaExcerpt Justification bases (#425)
* Add MediaExcerpt-based Justifications * Add text fragment to MediaExcerpt links * Fix URL substring validation --------- Signed-off-by: Carl Gieringer <78054+carlgieringer@users.noreply.github.com>
- Loading branch information
1 parent
c6a9c66
commit 9ef3e45
Showing
41 changed files
with
785 additions
and
200 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
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
import { extractDomain } from "./urls"; | ||
|
||
describe("urls", () => { | ||
describe("extractDomain", () => { | ||
it("should return undefined if url is undefined", () => { | ||
const url = undefined; | ||
const domain = extractDomain(url); | ||
expect(domain).toBeUndefined(); | ||
}); | ||
it("should return undefined if url is empty", () => { | ||
const url = ""; | ||
const domain = extractDomain(url); | ||
expect(domain).toBeUndefined(); | ||
}); | ||
it("should return undefined if url is not a valid url", () => { | ||
const url = "not a valid url"; | ||
const domain = extractDomain(url); | ||
expect(domain).toBeUndefined(); | ||
}); | ||
it("should return the domain if url is a valid url", () => { | ||
const url = "https://www.google.com"; | ||
const domain = extractDomain(url); | ||
expect(domain).toBe("www.google.com"); | ||
}); | ||
it("should return the domain if url is a valid url with a port", () => { | ||
const url = "https://www.google.com:8080"; | ||
const domain = extractDomain(url); | ||
expect(domain).toBe("www.google.com"); | ||
}); | ||
}); | ||
}); |
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,11 @@ | ||
export function extractDomain(url: string | undefined) { | ||
if (!url) { | ||
return undefined; | ||
} | ||
try { | ||
const urlObj = new URL(url); | ||
return urlObj.hostname; | ||
} catch (e) { | ||
return undefined; | ||
} | ||
} |
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
Oops, something went wrong.