diff --git a/src/api/encode.js b/src/api/encode.js new file mode 100644 index 0000000..5b63eb9 --- /dev/null +++ b/src/api/encode.js @@ -0,0 +1,6 @@ +export const encodeURL = (url)=>{ + if (url.indexOf('%') !== -1) { + return url + } + return encodeURIComponent(url) +} \ No newline at end of file diff --git a/src/api/product.js b/src/api/product.js index 5552c2d..318a13b 100644 --- a/src/api/product.js +++ b/src/api/product.js @@ -13,5 +13,5 @@ export const UpdateProduct=(p)=>{ } export const GetProduct = (pid) => { - return product.get(`p/${encodeURIComponent(pid)}`) + return product.get(`p/${encodeURL(pid)}`) } \ No newline at end of file diff --git a/src/api/provider.js b/src/api/provider.js index b4e8725..f365e9e 100644 --- a/src/api/provider.js +++ b/src/api/provider.js @@ -1,5 +1,6 @@ import {mande} from "mande"; import {queryRemoveZero} from "@/api/utils.js"; +import {encodeURL} from "@/api/encode.js"; const providers = mande('/api/v2/providers') @@ -47,13 +48,13 @@ export const FetchProviderArticlePrice = (providerArticle)=>{ } export const FetchProviderArticleAts = (providerArticle)=>{ - return provider.post(`/${providerArticle.providerId}/ats/fetch/${encodeURIComponent(providerArticle.skuID)}`) + return provider.post(`/${providerArticle.providerId}/ats/fetch/${encodeURL(providerArticle.skuID)}`) } export const GetProviderArticleAts = (providerId, pid)=>{ - return provider.get(`/${providerId}/ats/${encodeURIComponent(pid)}`) + return provider.get(`/${providerId}/ats/${encodeURL(pid)}`) } export const FetchProviderArticleDetail = (providerId, pid)=>{ - return provider.post(`/${providerId}/detail/fetch/${encodeURIComponent(pid)}`) + return provider.post(`/${providerId}/detail/fetch/${encodeURL(pid)}`) } \ No newline at end of file diff --git a/src/api/tracer.js b/src/api/tracer.js index aca9b0e..a7ef47e 100644 --- a/src/api/tracer.js +++ b/src/api/tracer.js @@ -1,6 +1,7 @@ import {mande} from "mande"; import {provider} from "@/api/provider.js"; import {queryRemoveZero} from "@/api/utils.js"; +import {encodeURL} from "@/api/encode.js"; const tracers = mande('/api/v2/tracers') @@ -10,13 +11,13 @@ export const ListTracers = (q) => { } export const CreateTracer = (providerId, skuID)=>{ - return provider.post(`${providerId}/ats-trace/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/ats-trace/${encodeURL(skuID)}`) } export const DeleteTracer = (providerId, skuID)=>{ - return provider.delete(`${providerId}/ats-trace/${encodeURIComponent(skuID)}`) + return provider.delete(`${providerId}/ats-trace/${encodeURL(skuID)}`) } export const StopTracer = (providerId,skuID)=>{ - return provider.post(`${providerId}/ats-trace/stop/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/ats-trace/stop/${encodeURL(skuID)}`) } \ No newline at end of file diff --git a/src/api/watcher.js b/src/api/watcher.js index bcef5d8..5c33d7e 100644 --- a/src/api/watcher.js +++ b/src/api/watcher.js @@ -1,6 +1,7 @@ import {mande} from "mande"; import {provider} from "@/api/provider.js"; import {queryRemoveZero} from "@/api/utils.js"; +import {encodeURL} from "@/api/encode.js"; const watchers = mande('/api/v2/watchers') @@ -10,13 +11,13 @@ export const ListWatchers = (q) => { } export const CreateWatcher = (providerId, skuID)=>{ - return provider.post(`${providerId}/watch/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/watch/${encodeURL(skuID)}`) } export const DeleteWatcher = (providerId, skuID)=>{ - return provider.delete(`${providerId}/watch/${encodeURIComponent(skuID)}`) + return provider.delete(`${providerId}/watch/${encodeURL(skuID)}`) } export const StopWatcher = (providerId,skuID)=>{ - return provider.post(`${providerId}/watch/stop/${encodeURIComponent(skuID)}`) + return provider.post(`${providerId}/watch/stop/${encodeURL(skuID)}`) } \ No newline at end of file