diff --git a/src/github/user/content.js b/src/github/user/content.js index e47d0b1..5dffc58 100644 --- a/src/github/user/content.js +++ b/src/github/user/content.js @@ -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 []; @@ -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`'; diff --git a/src/github/user/index.js b/src/github/user/index.js index 94fe527..57f10d2 100644 --- a/src/github/user/index.js +++ b/src/github/user/index.js @@ -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); diff --git a/src/github/user/user.stories.js b/src/github/user/user.stories.js index 5ce72c1..fb98e2d 100644 --- a/src/github/user/user.stories.js +++ b/src/github/user/user.stories.js @@ -12,7 +12,7 @@ export default { component: 'github-user', tags: ['autodocs'], render: (args) => { - console.log(args) + console.log({...args}) const attributes = attrGen(args); return ` @@ -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')) diff --git a/src/utils/index.js b/src/utils/index.js index 47581bd..a7dc23c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -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, '"'));