-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
127 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Slipmat Toolbelt DEV</title> | ||
</head> | ||
<body class="bg-slate-950"> | ||
<div id="app"></div> | ||
<script type="module" src="/src/dev.ts"></script> | ||
</body> | ||
</html> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Slipmat Toolbelt DEV</title> | ||
</head> | ||
|
||
<body class="bg-slate-950"> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<router-view></router-view> | ||
</template> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { storageAvailable, getCookie, copyToClipboard } from './browser' | ||
export { getNextPath } from './routes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import { createRouter, createWebHistory } from 'vue-router' | ||
|
||
import BrowserPage from './pages/BrowserPage.vue' | ||
import VuePage from './pages/VuePage.vue' | ||
|
||
const routes = [ | ||
{ path: '/', component: BrowserPage }, | ||
{ path: '/vue/', component: VuePage }, | ||
] | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(), | ||
routes, | ||
}) | ||
|
||
const app = createApp(App) | ||
app.use(router) | ||
app.mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script setup lang="ts"> | ||
import { getNextPath } from '../routes' | ||
const nextPath = getNextPath() | ||
console.log(`nextPath: ${nextPath}`) | ||
</script> | ||
<template></template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useRoute } from 'vue-router' | ||
import { isString } from './type-helpers' | ||
|
||
/** | ||
* Helper for figuring our ?next= query param in a safe way. | ||
*/ | ||
export function getNextPath(): string { | ||
const route = useRoute() | ||
|
||
let next = '/' | ||
if ( | ||
route.query && | ||
route.query.next && | ||
isString(route.query.next) && | ||
route.query.next.startsWith('/') | ||
) { | ||
next = route.query.next as string | ||
} | ||
return next | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { LocationQueryValue } from 'vue-router' | ||
|
||
export function isString(value: string | LocationQueryValue[]): value is string { | ||
return typeof value === 'string' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('getNextPath with no querypath should return "/"', async ({ page }) => { | ||
page.on('console', (msg) => { | ||
const text = msg.text() | ||
if (!text.startsWith('[vite]')) { | ||
expect(text).toBe('nextPath: /') | ||
} | ||
}) | ||
|
||
await page.goto('/vue/') | ||
}) | ||
|
||
test('getNextPath with next=foo should return "/"', async ({ page }) => { | ||
page.on('console', (msg) => { | ||
const text = msg.text() | ||
if (!text.startsWith('[vite]')) { | ||
expect(text).toBe('nextPath: /') | ||
} | ||
}) | ||
|
||
await page.goto('/vue/?next=foo') | ||
}) | ||
|
||
test('getNextPath with next=http://foo.bar should return "/"', async ({ page }) => { | ||
page.on('console', (msg) => { | ||
const text = msg.text() | ||
if (!text.startsWith('[vite]')) { | ||
expect(text).toBe('nextPath: /') | ||
} | ||
}) | ||
|
||
await page.goto('/vue/?next=http://foo.bar') | ||
}) | ||
|
||
test('getNextPath with next=/next-url/ should return "/next-url/"', async ({ page }) => { | ||
page.on('console', (msg) => { | ||
const text = msg.text() | ||
if (!text.startsWith('[vite]')) { | ||
expect(text).toBe('nextPath: /next-url/') | ||
} | ||
}) | ||
|
||
await page.goto('/vue/?next=/next-url/') | ||
}) |