Feature(code-uri): Load and remove code uri on loadCode

This commit is contained in:
Berkeley Martinez
2016-08-15 12:10:09 -07:00
parent 3f3aab3ff7
commit c919ce5dc8
5 changed files with 46 additions and 3 deletions

View File

@@ -49,7 +49,7 @@ export function getLegacySolutionFromQuery(query = '', decode) {
)(query, 'solution');
}
export function getCodeUri({ location, decodeURIComponent }) {
export function getCodeUri(location, decodeURIComponent) {
let query;
if (
location.search &&
@@ -62,3 +62,18 @@ export function getCodeUri({ location, decodeURIComponent }) {
return getLegacySolutionFromQuery(query, decodeURIComponent);
}
export function removeCodeUri(location, history) {
if (
typeof location.search.split !== 'function' ||
typeof history.replaceState !== 'function'
) {
return false;
}
history.replaceState(
history.state,
null,
location.search.split('?')[0]
);
return true;
}