buypeeb-cs/BuypeebApp.cs

32 lines
802 B
C#

using System;
using Gtk;
using System.Text.RegularExpressions;
namespace Buypeeb {
class BuypeebApp {
[STAThread]
public static void Main(string[] args) {
Application.Init();
var app = new Application("space.lynnesbian.Buypeeb", GLib.ApplicationFlags.None);
app.Register(GLib.Cancellable.Current);
var win = new MainWindow();
app.AddWindow(win);
win.Show();
Application.Run();
}
public static string IDFromURL(string url) {
// TODO: handle invalid URLs better, or at all really
Regex rx = new Regex(@"^([^?#]+)");
url = rx.Match(url).Groups[1].Value; // remove query params (if any)
rx = new Regex(@".+\/(.+?)/?$");
string id = rx.Match(url).Groups[1].Value; // extracts "k12345" from "https://buypeeb.biz/whatever/k12345/"
return id;
}
}
}