Skip to main content

resolve_source_map_url

Function resolve_source_map_url 

Source
pub fn resolve_source_map_url(
    minified_url: &str,
    source_map_ref: &str,
) -> Option<String>
Expand description

Resolve a relative sourceMappingURL against the minified file’s URL.

  • If source_map_ref is already absolute (starts with http://, https://, or /), returns it as-is.
  • If source_map_ref starts with data:, returns None (inline maps).
  • Otherwise, replaces the filename portion of minified_url with source_map_ref and handles ../ traversal.

§Examples

use srcmap_sourcemap::utils::resolve_source_map_url;
let url = resolve_source_map_url("https://example.com/js/app.js", "app.js.map");
assert_eq!(url, Some("https://example.com/js/app.js.map".to_string()));