Bitsmist Frameworks
Docs » URLUtil

URLUtil

Overview

URLUtil is a utility class that performs URL-related tasks.

Methods

buildQuery(options)

Type:String Static

Generates the query part of a URL from the object given in the argument. Each key and value is URLEncoded. If an item in the options is an array, each element is concatenated with a comma.

Parameters

ParameterTypeDescription
options
Required
ObjectThe URL query parameter object.

Return Value

Returns the URL query string. If the query string is not empty, a leading ? is prepended to the query string.


buildURL(routeInfo, options)

Type:String Static

Generates a URL based on the specified route information object.

If “URL” is included in the route information, it is used as is; otherwise, “protocol”, “host”, and “pathname” are concatenated to generate the URL. The contents of the current URL are used for missing parts.

If “query” is included in the route information, it is used as the query part. If “queryParameters” is included, the query part is generated based on that object and appended to the URL.

Parameters

ParameterTypeDescription
routeInfo
Required
ObjectThe Route information object. Has the following keys:
“URL“StringThe URL without query part.
“protocol”StringThe protocol part of the URL.
“host”StringThe host part of the URL.
“pathname”StringThe pathname part of the URL.
“query”ObjectThe query part of the URL.
“queryParameters”ObjectThe query object to build query part.
optionsObjectOptions. Has the following keys:
“mergeParameters”StringIf true, merges the generated query into the current URL query.

Return Value

The generated URL.


loadParameters(url)

Type:Object Static

Converts the query part of the specified URL into a Javascript object.

Parameters

ParameterTypeDescription
urlStringThe target URL. If not specified, the current URL is used.

Return Value

The query object.


parseURL(url)

Type:Object Static

Returns the object that decomposes the given URL. The object has the following information:

KeyTypeDescription
protocolStringThe protocol part of the URL.
usernameStringThe username part of the URL.
passwordStringThe password part of the URL.
hostStringThe host part of the URL. If a port is specified, the port is also included.
hostnameStringThe host part of the URL.
portStringThe port part of the URL.
pathnameStringThe path part of the URL.
pathStringThe path part of the URL without the filename part.
searchStringThe query part of the URL.
queryStringThe query part of the URL.
hashStringThe hash part of the URL.
filenameStringThe filename part of the URL.
filenameWithoutExtensionStringThe filename part of the URL without extension.
extensionStringThe filename extension part of the URL.
queryParametersObjectThe query part of the URL, converted to an object.

Parameters

ParameterTypeDescription
urlStringThe target URL. If not specified, the current URL will be used.

Return Value

URL information object.

Previous Next

© 2019-2023 Masaki Yasutake

Bitsmist Frameworks

Table of Contents

Table of Contents

  • URLUtil
    • Overview
    • Methods
      • buildQuery(options)
      • buildURL(routeInfo, options)
      • loadParameters(url)
      • parseURL(url)

Introduction

  • Overview
  • Installation
  • Create a Sample Unit

Unit Explained

  • Overview
  • Properties and Methods
  • Settings
  • Loading
  • Events
  • HTML
  • CSS
  • Extending with Perks

Reference - Unit

  • Unit

Reference - Perk

  • Perk (Base Class)
  • BasicPerk
  • EventPerk
  • PerkPerk
  • SettingPerk
  • SkinPerk
  • StatusPerk
  • StylePerk
  • UnitPerk

Reference - Store

  • Store
  • ChainableStore

Reference - Utility

  • AjaxUtil
  • ClassUtil
  • URLUtil
  • Util