Skip to content

Commit

Permalink
Update chance:// url scheme for multi-site
Browse files Browse the repository at this point in the history
  • Loading branch information
moffatman committed Jul 8, 2022
1 parent d044bf7 commit 08fa360
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Chance.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
document.body.appendChild(button)
button.innerHTML = 'Open in Chance'
button.onclick = () => {
document.location = 'chance:/' + document.location.pathname
document.location = 'chance://4chan' + document.location.pathname
}
button.style.position = 'fixed'
button.style.right = '10px';
Expand Down
7 changes: 4 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,13 @@ class _ChanHomePageState extends State<ChanHomePage> {
void _onNewLink(String? link) {
if (link != null && link.startsWith('chance:')) {
print(link);
final threadLink = RegExp(r'chance:\/\/([^\/]+)\/thread\/(\d+)').firstMatch(link);
final threadLink = RegExp(r'chance:\/\/([^\/]+)\/([^\/]+)\/thread\/(\d+)').firstMatch(link);
if (threadLink != null) {
_addNewTab(
withImageboardKey: threadLink.group(1)!,
withThread: ThreadIdentifier(
threadLink.group(1)!,
int.parse(threadLink.group(2)!)
threadLink.group(2)!,
int.parse(threadLink.group(3)!)
),
activate: true
);
Expand Down

0 comments on commit 08fa360

Please sign in to comment.