Interface: Path

Path

Path utilities for working with URLs and file paths in a cross-platform way. All paths that are passed in will become normalized to have posix separators.

import { path } from 'pixi.js';

path.normalize('http://www.example.com/foo/bar/../baz'); // http://www.example.com/foo/baz
Properties:
Name Type Description
basename (path: string, ext: string) => string

Returns the last portion of a path

dirname (path: string) => string

Returns the directory name of a path

extname (path: string) => string

Returns the extension of the path, from the last occurrence of the . (period) character to end of string in the last portion of the path. If there is no . in the last portion of the path, or if there are no . characters other than the first character of the basename of path, an empty string is returned.

getProtocol (path: string) => string

Returns the protocol of the path e.g. http://, https://, file:///, data:, blob:, C:/

hasProtocol (path: string) => boolean

Checks if the path has a protocol e.g. http://, https://, file:///, data:, blob:, C:/ This will return true for windows file paths

isAbsolute (path: string) => boolean

Determines if path is an absolute path. Absolute paths can be urls, data urls, or paths on disk

isBlobUrl (path: string) => boolean

Checks if the path is a blob URL

isDataUrl (path: string) => boolean

Checks if the path is a data URL

isUrl (path: string) => boolean

Checks if the path is a URL e.g. http://, https://

join (...paths: string[]) => string

Joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path

normalize (path: string) => string

Normalizes the given path, resolving '..' and '.' segments

parse (path: string) => { root? : string, dir? : string, base? : string, ext? : string, name? : string }

Parses a path into an object containing the 'root', dir, base, ext, and name properties.

rootname (path: string) => string

Returns the root of the path e.g. /, C:/, file:///, http://domain.com/

toAbsolute (url: string, baseUrl: string, rootUrl: string) => string

Converts URL to an absolute path. When loading from a Web Worker, we must use absolute paths. If the URL is already absolute we return it as is If it's not, we convert it

toPosix (path: string) => string

Converts a path to posix format.

Members

basename (path: string, ext: string) => string

Returns the last portion of a path

dirname (path: string) => string

Returns the directory name of a path

extname (path: string) => string

Returns the extension of the path, from the last occurrence of the . (period) character to end of string in the last portion of the path. If there is no . in the last portion of the path, or if there are no . characters other than the first character of the basename of path, an empty string is returned.

getProtocol (path: string) => string

Returns the protocol of the path e.g. http://, https://, file:///, data:, blob:, C:/

hasProtocol (path: string) => boolean

Checks if the path has a protocol e.g. http://, https://, file:///, data:, blob:, C:/ This will return true for windows file paths

isAbsolute (path: string) => boolean

Determines if path is an absolute path. Absolute paths can be urls, data urls, or paths on disk

isBlobUrl (path: string) => boolean

Checks if the path is a blob URL

isDataUrl (path: string) => boolean

Checks if the path is a data URL

isUrl (path: string) => boolean

Checks if the path is a URL e.g. http://, https://

join (...paths: string[]) => string

Joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path

normalize (path: string) => string

Normalizes the given path, resolving '..' and '.' segments

parse (path: string) => { root? : string, dir? : string, base? : string, ext? : string, name? : string }

Parses a path into an object containing the 'root', dir, base, ext, and name properties.

rootname (path: string) => string

Returns the root of the path e.g. /, C:/, file:///, http://domain.com/

toAbsolute (url: string, baseUrl: string, rootUrl: string) => string

Converts URL to an absolute path. When loading from a Web Worker, we must use absolute paths. If the URL is already absolute we return it as is If it's not, we convert it

toPosix (path: string) => string

Converts a path to posix format.