Skip to content

Commit

Permalink
feat(esl-utils): added URL utility with toAbsoluteUrl method
Browse files Browse the repository at this point in the history
  • Loading branch information
dshovchko committed Mar 3, 2023
1 parent a7f35c2 commit ac5f7ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/modules/esl-utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * as ArrayUtils from './misc/array';
export * as ObjectUtils from './misc/object';
export * as FormatUtils from './misc/format';
export * as FunctionUtils from './misc/functions';
export * as UrlUtils from './misc/url';

export {sequentialUID, randUID} from './misc/uid';
export {range, tuple, wrap, uniq} from './misc/array';
Expand Down
8 changes: 8 additions & 0 deletions src/modules/esl-utils/misc/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Converts relative URL to absolute URL based on the base URL.
* @param relative - relative URL
* @param base - base URL (document.baseURI by default)
**/
export function toAbsoluteUrl(relative: string, base: string = document.baseURI): string {
return new URL(relative, base).href;
}

0 comments on commit ac5f7ed

Please # to comment.