Skip to content

Commit

Permalink
bugz
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnath committed Mar 5, 2024
1 parent 5036364 commit 4d75cc0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/github/user/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ export const parseFetchedUser = (user = {}) => {
export const parseReposString = (reposStr, owner) => {
if (typeof reposStr !== 'string') return reposStr;
let repos = [];
console.log(reposStr);
try {
repos = parseify(reposStr);
console.log('repos', repos);
} catch (error) {
console.error(error);
return [];
Expand Down Expand Up @@ -117,6 +119,7 @@ export const cleanUserContent = (content = {}) => {
if (content.username && !content.login) {
content.login = content.username;
}
console.log('content', content);
const user = parseFetchedUser(content);
if (!user.login) {
user.error = 'Missing required attribute: `login` || `username`';
Expand Down
1 change: 1 addition & 0 deletions src/github/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class GitHubUser extends HTMLElement {
async connectedCallback() {
this.#adoptStyles();
let view = ``;
console.log('this.attrs', this.attrs);
this.content = await generateUserContent(this.attrs, this.attrs.fetch);
console.log('connectedCallback', this.content)
view += html(this.content);
Expand Down
4 changes: 2 additions & 2 deletions src/github/user/user.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
component: 'github-user',
tags: ['autodocs'],
render: (args) => {
console.log(args)
console.log({...args})
const attributes = attrGen(args);

return `
Expand All @@ -35,7 +35,7 @@ export const UserRepos = {
args: {
...User.args,
name: 'Scoot Nerth',
repos: stringify([{ ...parseFetchedRepo(repoProfileComponents), user_login: userScottnath.login }, parseFetchedRepo(repoStorydocker)]),
repos: stringify([parseFetchedRepo(repoProfileComponents), parseFetchedRepo(repoStorydocker)]),
},
play: async ({ args, canvasElement, step }) => {
console.log('UserRepos = canva', canvasElement.closest('body'))
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export const intToString = (num) => {
* @param {Object} obj
* @returns {string} stringified object with quotes escaped
*/
export const stringify = (obj) => encodeURIComponent(JSON.stringify(obj))
export const stringify = (obj) => JSON.stringify(obj).replace(/"/g, """);

/**
* Parse a stringified object with quotes escaped
* @param {string} str
* @returns {Object} parsed object
*/
export const parseify = (str) => JSON.parse(decodeURIComponent(str));
export const parseify = (str) => JSON.parse(str.replace(/"/g, '"'));

0 comments on commit 4d75cc0

Please sign in to comment.