Skip to content

fooHQ/urlpath

Repository files navigation

urlpath

urlpath release (latest SemVer) Go Reference

The urlpath module provides utility functions for manipulating file paths and URLs. It supports a variety of path formats, including Unix, Windows, and URL notations.

Supported path formats include:

  • Unix: /home/user/file.txt, ../otherfile.txt
  • URL: file:///home/user/file.txt, http://www.example.com/assets/file.js
  • Windows (DOS): C:\Windows\System32\cmd.exe
  • Windows (UNC): \\10.10.0.55\COMP\customers.xls

Note

DOS and UNC paths are only supported when GOOS=windows.

Installation

go get github.com/foohq/urlpath

Usage

import "github.com/foohq/urlpath"

dir, base, err := urlpath.Split("http://www.example.com/assets/file.js")
if err != nil {
	panic(err)
}

println(dir)
// Prints "http://www.example.com/assets"
println(base)
// Prints "file.js"

pth, err := urlpath.Join(dir, "another.js")
if err != nil {
	panic(err)
} 

println(pth)
// Prints "http://www.example.com/assets/another.js"

License

This module is distributed under the Apache License Version 2.0 found in the LICENSE file.

About

Utility functions for manipulating file paths and URLs.

Resources

License

Stars

Watchers

Forks

Languages