Skip to content

Commit e1a142b

Browse files
committed
chore: handle / in src and path
1 parent da20241 commit e1a142b

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

example/sample-app/src/App.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
<script>
5050
import { IKImage, IKContext, IKUpload } from "imagekitio-vue";
5151
52+
let urlEndpoint= process.env.VUE_APP_URL_ENDPOINT;
53+
if(urlEndpoint[urlEndpoint.length-1] === "/")
54+
urlEndpoint = urlEndpoint.slice(0,urlEndpoint.length-1);
55+
56+
let path = "/default-image.jpg";
57+
if(path[0] === "/")
58+
path = path.split("/")[1];
59+
5260
export default {
5361
name: "app",
5462
components: {
@@ -58,11 +66,11 @@ export default {
5866
},
5967
data() {
6068
return {
61-
urlEndpoint: process.env.VUE_APP_URL_ENDPOINT,
69+
urlEndpoint: urlEndpoint,
6270
publicKey: process.env.VUE_APP_PUBLIC_KEY,
6371
authenticationEndpoint: process.env.VUE_APP_AUTHENTICATION_ENDPOINT,
64-
path: "default-image.jpg",
65-
src: `${urlEndpoint}${path}`
72+
path: path,
73+
src: `${urlEndpoint}/${path}`
6674
};
6775
}
6876
};

tests/stories/0-ImageKitContext.stories.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ export default {
44
title: 'IKContext',
55
};
66

7-
8-
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
97
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
10-
const path = "default-image.jpg";
11-
const src = `${urlEndpoint}${path}`;
8+
9+
let urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
10+
if(urlEndpoint[urlEndpoint.length-1] === "/")
11+
urlEndpoint = urlEndpoint.slice(0,urlEndpoint.length-1);
12+
13+
let path = "/default-image.jpg";
14+
if(path[0] === "/")
15+
path = path.split("/")[1];
16+
17+
const src = `${urlEndpoint}/${path}`;
1218

1319
export const imageWithContext = () => ({
1420
components: { IKImage, IKContext },

tests/stories/1-ImageKitImage.stories.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ export default {
44
title: 'IKImage',
55
};
66

7-
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
87
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
9-
const path = "default-image.jpg";
8+
9+
let urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
10+
if(urlEndpoint[urlEndpoint.length-1] === "/")
11+
urlEndpoint = urlEndpoint.slice(0,urlEndpoint.length-1);
12+
13+
let path = "/default-image.jpg";
14+
if(path[0] === "/")
15+
path = path.split("/")[1];
16+
1017
const src = `${urlEndpoint}${path}`;
1118

1219
export const imageWithSrc = () => ({

tests/stories/2-Transformations.stories.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ export default {
44
title: 'Transformations',
55
};
66

7-
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
87
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
9-
const path = "default-image.jpg";
10-
const src = `${urlEndpoint}${path}`;
8+
9+
let urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
10+
if(urlEndpoint[urlEndpoint.length-1] === "/")
11+
urlEndpoint = urlEndpoint.slice(0,urlEndpoint.length-1);
12+
13+
let path = "/default-image.jpg";
14+
if(path[0] === "/")
15+
path = path.split("/")[1];
16+
17+
const src = `${urlEndpoint}/${path}`;
1118

1219
export const imageWithTransformation = () => ({
1320
components: { IKImage },

0 commit comments

Comments
 (0)