// Resolve a bundled-data path. Inside the extension this maps to
// chrome-extension://<id>/data/...; when the folder is served statically (Node
// tests, preview) it falls back to a path relative to src/.
export function dataURL(p) {
  if (typeof chrome !== "undefined" && chrome.runtime && chrome.runtime.getURL) {
    return chrome.runtime.getURL("data/" + p);
  }
  return "../data/" + p;
}

export function esc(s) {
  return (s == null ? "" : String(s))
    .replace(/&/g, "&amp;")
    .replace(/</g, "&lt;")
    .replace(/>/g, "&gt;")
    .replace(/"/g, "&quot;");
}
