/**
 * @description 路径处理工具，提供路径拼接与解析功能
 * @author D吕贺034244311
 * @date 20260615
 */
/**
 * 简易路径解析工具，替代 Node.js path 模块（Vite 不提供 Node polyfill）
 * 用法: resolve('/sys', 'config') => '/sys/config'
 */
export function resolve(...segments) {
  let joined = segments.join('/')
  // 去除重复斜杠
  joined = joined.replace(/\/+/g, '/')
  // 确保以 / 开头
  if (!joined.startsWith('/')) joined = '/' + joined
  // 去除末尾斜杠（除非就是根路径）
  if (joined.length > 1 && joined.endsWith('/')) joined = joined.slice(0, -1)
  return joined
}
