Files
talk/client/coral-framework/utils/url.js
T
Wyatt Johnson c19d4a433a Improved Comment URL Handling (#1860)
* feat: replaces PR 1819

- fixes #1851

* fix: set query using new syntax

* review: fixes for missed framework changes

* fix: linting
2018-09-11 22:44:23 +00:00

22 lines
520 B
JavaScript

import parse from 'url-parse';
export function buildUrl(
{ protocol, hostname, port, pathname, search, hash } = window.location
) {
if (search && search[0] !== '?') {
search = `?${search}`;
} else if (search === '?') {
search = '';
}
return `${protocol}//${hostname}${
port ? `:${port}` : ''
}${pathname}${search}${hash}`;
}
export function buildCommentURL(assetURL, commentID) {
const u = parse(assetURL, true);
u.query.commentId = commentID;
u.set('query', u.query);
return u.href;
}