2020-08-28 16:04:37 +00:00
|
|
|
|
using System;
|
2020-09-02 03:21:32 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2021-06-15 00:20:46 +00:00
|
|
|
|
using GLib;
|
|
|
|
|
using Application = Gtk.Application;
|
2020-08-28 16:04:37 +00:00
|
|
|
|
|
|
|
|
|
namespace Buypeeb {
|
2021-06-15 00:20:46 +00:00
|
|
|
|
internal class BuypeebApp {
|
2020-08-28 16:04:37 +00:00
|
|
|
|
[STAThread]
|
|
|
|
|
public static void Main(string[] args) {
|
|
|
|
|
Application.Init();
|
|
|
|
|
|
2021-06-15 00:20:46 +00:00
|
|
|
|
var app = new Application("space.lynnesbian.Buypeeb", ApplicationFlags.None);
|
|
|
|
|
app.Register(Cancellable.Current);
|
2020-08-28 16:04:37 +00:00
|
|
|
|
|
|
|
|
|
var win = new MainWindow();
|
|
|
|
|
app.AddWindow(win);
|
|
|
|
|
|
|
|
|
|
win.Show();
|
|
|
|
|
Application.Run();
|
|
|
|
|
}
|
2020-09-02 03:21:32 +00:00
|
|
|
|
|
2021-06-15 00:20:46 +00:00
|
|
|
|
// ReSharper disable once InconsistentNaming
|
|
|
|
|
// i prefer "IDFromURL" to "IdFromUrl". also i will never forgive microsoft for the name of XmlHTTPRequest and you
|
|
|
|
|
// may consider this an act of spite/revenge
|
2020-09-02 03:21:32 +00:00
|
|
|
|
public static string IDFromURL(string url) {
|
|
|
|
|
// TODO: handle invalid URLs better, or at all really
|
2021-06-15 00:20:46 +00:00
|
|
|
|
var rx = new Regex(@"^([^?#]+)");
|
2020-09-02 03:21:32 +00:00
|
|
|
|
url = rx.Match(url).Groups[1].Value; // remove query params (if any)
|
|
|
|
|
|
|
|
|
|
rx = new Regex(@".+\/(.+?)/?$");
|
2021-06-15 00:20:46 +00:00
|
|
|
|
var id = rx.Match(url).Groups[1].Value; // extracts "k12345" from "https://buypeeb.biz/whatever/k12345/"
|
2020-09-02 03:21:32 +00:00
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
2020-08-28 16:04:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|