Lynne
b26326baf5
- use var instead of specific type names where applicable - get user's home directory from Environment.SpecialFolder.UserProfile instead of reading the HOME environment variable, which isn't always set - use object initialisers where possible - remove redundant identifiers (e.g. "Gtk.Application.Invoke" becomes "Application.Invoke"), of which there were MANY - remove unused local variables - replace "variable as Class" with "(Class) variable" - many other miscellaneous improvements thanks rider 0u0
36 lines
1 KiB
C#
36 lines
1 KiB
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
using GLib;
|
|
using Application = Gtk.Application;
|
|
|
|
namespace Buypeeb {
|
|
internal class BuypeebApp {
|
|
[STAThread]
|
|
public static void Main(string[] args) {
|
|
Application.Init();
|
|
|
|
var app = new Application("space.lynnesbian.Buypeeb", ApplicationFlags.None);
|
|
app.Register(Cancellable.Current);
|
|
|
|
var win = new MainWindow();
|
|
app.AddWindow(win);
|
|
|
|
win.Show();
|
|
Application.Run();
|
|
}
|
|
|
|
// 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
|
|
public static string IDFromURL(string url) {
|
|
// TODO: handle invalid URLs better, or at all really
|
|
var rx = new Regex(@"^([^?#]+)");
|
|
url = rx.Match(url).Groups[1].Value; // remove query params (if any)
|
|
|
|
rx = new Regex(@".+\/(.+?)/?$");
|
|
var id = rx.Match(url).Groups[1].Value; // extracts "k12345" from "https://buypeeb.biz/whatever/k12345/"
|
|
|
|
return id;
|
|
}
|
|
}
|
|
}
|