pob-parser
v1.0.2
Published
Path of Building (PoB) import code and pobb.in URL parser
Downloads
59
Maintainers
Readme
pob-parser
A high-performance, robust, and zero-dependency library for parsing, encoding, decoding, and fetching Path of Building (PoB) import codes and pobb.in links. Available in both TypeScript/JavaScript (npm) and Rust (crates.io).
Features
- Zero external dependencies (JS/TS version) using modern Web Streams.
- High performance and safe encoding/decoding using base64 and zlib.
- Link parsing and retrieval: Resolves standard and user-profile URLs for pobb.in to fetch the raw import codes.
- Idiomatic Rust version with conditional async/blocking fetching using features.
- Local playground demo: A minimal, terminal-inspired web application included in the repository to test, edit, and re-encode builds.
Installation
TypeScript / JavaScript (npm)
npm install pob-parserRust (crates.io)
Add to your Cargo.toml:
[dependencies]
pob-parser = "1.0.2"To enable HTTP fetching (async/blocking):
pob-parser = { version = "1.0.2", features = ["fetch", "blocking"] }Quick Start Examples
TypeScript / JavaScript
import { encode, decode, parseUrl, fetchRawCode, fetchAndDecode } from 'pob-parser';
// 1. Decode a PoB code to XML
const pobCode = "eJzLSM3JyVcozy/KSQEAGgsEXQ=="; // "hello world" compressed
const xml = await decode(pobCode);
console.log(xml); // "hello world"
// 2. Encode XML to PoB Code
const newPobCode = await encode(xml);
console.log(newPobCode); // "eJzLSM3JyVcozy_KSQEAGgsEXQ" (URL-safe, no padding)
// 3. Parse a pobb.in URL
const parsed = parseUrl("https://pobb.in/eQVFNoqVZrza");
console.log(parsed);
// { id: 'eQVFNoqVZrza', rawUrl: 'https://pobb.in/eQVFNoqVZrza/raw' }
// 4. Fetch and decode from pobb.in
const fetchedXml = await fetchAndDecode("https://pobb.in/eQVFNoqVZrza");
console.log(fetchedXml);Rust
use pob_parser::{decode, encode, parse_url};
fn main() -> Result<(), pob_parser::Error> {
// 1. Decode PoB code
let xml = decode("eJzLSM3JyVcozy/KSQEAGgsEXQ==")?;
println!("{}", xml); // "hello world"
// 2. Encode XML
let encoded = encode(&xml)?;
println!("{}", encoded); // "eJzLSM3JyVcozy_KSQEAGgsEXQ"
// 3. Parse pobb.in link
let parsed = parse_url("https://pobb.in/eQVFNoqVZrza").unwrap();
println!("Raw URL: {}", parsed.raw_url);
Ok(())
}
// 4. Fetch and decode (requires the "fetch" feature)
#[cfg(feature = "fetch")]
async fn fetch_example() -> Result<(), pob_parser::Error> {
let xml = pob_parser::fetch_and_decode("https://pobb.in/eQVFNoqVZrza", None).await?;
println!("{}", xml);
Ok(())
}Local Playground
Run Locally with CORS Proxy
Since browsers block cross-origin requests (CORS) when executing client-side fetches directly to pobb.in, a local dev server with a built-in proxy is provided for testing:
- Build the library bundles:
cd js npm run build - Start the dev server:
npm start - Open http://localhost:3000 in your browser to access the playground.
Credits
- PathOfBuildingAPI by ppoelzl
- pasteofexile by Dav1dde
