package com.bsphp.login;

import java.awt.Desktop;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

final class SaleWebUtil {

    private SaleWebUtil() {}

    static void open(String url) {
        try {
            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(URI.create(url));
            }
        } catch (Exception ignored) {
        }
    }

    static String renewUrlForUser(String base, String user) {
        if (user == null || user.isBlank()) return base;
        String t = user.trim();
        String sep = base.contains("?") ? "&" : "?";
        return base + sep + "user=" + URLEncoder.encode(t, StandardCharsets.UTF_8);
    }
}
