Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-useurl

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-useurl - npm Package Compare versions

Comparing version 1.0.17 to 1.0.18

LICENSE

3

package.json
{
"name": "vue-useurl",
"version": "1.0.17",
"version": "1.0.18",
"description": "Url Builder Hook for Vue.js Composition API",

@@ -29,2 +29,3 @@ "main": "src/index.js",

"dependencies": {
"typedoc": "^0.22.15",
"vue-demi": "latest"

@@ -31,0 +32,0 @@ },

<img src="https://raw.githubusercontent.com/rainxh11/vue-useurl/master/assets/logo.svg" width="300">
# vue-useurl ( Url Builder Vue Hook )
# vue-useurl ( Reactive Url Builder Vue Hook for Vue 2 & Vue 3 )
[![NPM version](https://img.shields.io/npm/v/vue-useurl.svg)](https://www.npmjs.com/package/vue-useurl)
A library for building URL using ***(Query Parameters, Path Variables, Hash)*,** while being reactive and ready to use as Vue Composition API Hook
A library for building URL using ***(Query Parameters, Path Variables, Hash, Path)*** while being reactive and ready to use as Vue Composition API Hook

@@ -22,19 +22,19 @@ ## Installation

const params = {
search: 'ahmed',
limit: 50,
page: 12,
sort: 'CreatedOn',
types: ['Cancelled', 'OnGoing']
search: 'ahmed',
limit: 50,
page: 12,
sort: 'CreatedOn',
types: ['Cancelled', 'OnGoing']
}
const { url, queryParams, pathVariables, hash, path, disableCSV } = useUrl({
path: '/api/v1/users/:id/search',
pathVariables: {
id: 451
},
queryParams: {
...params
},
hash: 'someHash',
disableCSV: false
path: '/api/v1/users/:id/search',
pathVariables: {
id: 451
},
queryParams: {
...params
},
hash: 'someHash',
disableCSV: false
},

@@ -51,14 +51,14 @@ 'http://api.com')

path: '/path/path1', // URL Path
pathVariables: {
id: 451
}, // Path variables e.g: /:id/
queryParams: {
limit:10,
sortBy: 'property',
page: 1
}, // Query parameters
hash: 'someHash', // Hash
disableCSV: false
// Enabled: param=1&param=2&param=3
// Disabled: param=1,2,3
pathVariables: {
id: 451
}, // Path variables e.g: /:id/
queryParams: {
limit:10,
sortBy: 'property',
page: 1
}, // Query parameters
hash: 'someHash', // Hash
disableCSV: false
// Enabled: param=1&param=2&param=3
// Disabled: param=1,2,3
}

@@ -70,3 +70,3 @@ ```

```ts
buildUrl('http://example.com', {
buildUrl('http://api.com', {
path: 'about',

@@ -97,24 +97,23 @@ hash: 'hash',

const { url, queryParams, pathVariables, hash, path, disableCSV } = useUrl({
path: '/api/v1/users/:id/search',
pathVariables: {
id: 451
},
queryParams: {
search: 'ahmed',
limit: 50,
page: 12,
sort: 'CreatedOn',
types: ['Cancelled', 'OnGoing']
},
hash: 'hashtag',
disableCSV: false
path: '/api/v1/users/:id/search',
pathVariables: {
id: 451
},
queryParams: {
search: 'ahmed',
limit: 50,
page: 12,
sort: 'CreatedOn',
types: ['Cancelled', 'OnGoing']
},
hash: 'hashtag',
disableCSV: false
},
'http://api.com')
const { isFetching, error, data } = useFetch<Contact[]>(
const { isFetching, error, data } = useFetch(
url,
{ initialData: { results: [] }, refetch: true}
)
.get()
.json()
{ initialData: { results: [] }, refetch: true})
.get()
.json()
```

@@ -134,25 +133,23 @@

const { url, queryParams, pathVariables, hash, path, disableCSV } = useUrl({
path: '/api/v1/users/:id/search',
pathVariables: {
id: 451
},
queryParams: {
search: useDebounce(search, 500), //
limit: 50,
page: 12,
sort: 'CreatedOn',
types: useDebounce(filters, 3500) // then pass their reactive backpressure objects instead
},
hash: 'hashtag',
disableCSV: false
path: '/api/v1/users/:id/search',
pathVariables: {
id: 451
},
queryParams: {
search: useDebounce(search, 500), //
limit: 50,
page: 12,
sort: 'CreatedOn',
types: useDebounce(filters, 3500) // then pass their reactive backpressure objects instead
},
hash: 'hashtag',
disableCSV: false
},
'http://api.com')
const { isFetching, error, data } = useFetch<Contact[]>(
const { isFetching, error, data } = useFetch(
url,
{ initialData: { results: [] }, refetch: true}
)
.get()
.json()
}
{ initialData: { results: [] }, refetch: true})
.get()
.json()

@@ -173,5 +170,4 @@ return {

## License
This is licensed under an MIT License. (LICENSE)
This is licensed under an MIT License.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useUrl = exports.UrlBuilder = exports.BuilderResult = void 0;
exports.createUseUrlInstance = exports.useUrl = exports.UrlBuilder = exports.BuilderResult = void 0;
const vue_demi_1 = require("vue-demi");

@@ -65,2 +65,15 @@ (0, vue_demi_1.install)();

exports.UrlBuilder = UrlBuilder;
/**
* Create a reactive url
* @param {IUrlOptions | any} options Builder Options
* @param {string} baseUrl Base URL
* @returns {IBuilderResult} `{
* url,
* queryParams,
* pathVariables,
* hash,
* path,
* disableCSV
* }`
*/
const useUrl = (options, baseUrl) => {

@@ -82,1 +95,10 @@ const builderResult = new BuilderResult(options.path, options.pathVariables, options.queryParams, options.hash, options.disableCSV);

exports.useUrl = useUrl;
/**
* Create a new instance of useUrl()
* @param {string} baseUrl Base URL
* @returns {function} Instance function
*/
const createUseUrlInstance = (baseUrl = '') => {
return useUrl(baseUrl);
};
exports.createUseUrlInstance = createUseUrlInstance;

@@ -95,3 +95,16 @@ import { ref, reactive, computed, Ref, UnwrapRef, ComputedRef, install } from 'vue-demi';

export const useUrl = (options:IUrlOptions|any, baseUrl?:string):IBuilderResult => {
/**
* Create a reactive url
* @param {IUrlOptions | any} options Builder Options
* @param {string} baseUrl Base URL
* @returns {IBuilderResult} `{
* url,
* queryParams,
* pathVariables,
* hash,
* path,
* disableCSV
* }`
*/
const useUrl = (options:IUrlOptions|any, baseUrl?:string):IBuilderResult => {
const builderResult = new BuilderResult(

@@ -119,2 +132,14 @@ options.path,

return builderResult
}
}
/**
* Create a new instance of useUrl()
* @param {string} baseUrl Base URL
* @returns {function} Instance function
*/
const createUseUrlInstance = (baseUrl:string = '') => {
return useUrl(baseUrl)
}
export { useUrl, createUseUrlInstance }
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc