moxystudio / js-proper-url-join Goto Github PK
View Code? Open in Web Editor NEWLike path.join but for a URL
License: MIT License
Like path.join but for a URL
License: MIT License
We have a case where we have to build urls programmatically and want to keep the leading and trailing slashes if there are any.
It would be great to have a third option e.g trailingSlash : 'keep'
to support this use case.
I am trying to join path for the router (which is using path-to-regexp).
const path = properUrlJoin('some-path', '/:id?/:subnav?/:step?', {
trailingSlash: true,
queryOptions: {
encode: false,
},
})
expected output should be
/some-path/:id?/:subnav?/:step?/
but it results to
/flow/:id/?/:subnav?/:step?β
It will be great if you add this, replace in url something like that:
urlJoin('foo/bar/users/:id/profile', { ':id': 14 })
// => foo/bar/users/14/profile
may be like that...
if (key == 'leadingSlash') {...}
else if (key == 'trailingSlash') {...}
else if (key == 'protocolRelative') {..}
.
.
... else {
// try to replace in url
if (url.indexOf(key)) url = url.replace(key, value)
}
or may be like that :
{ query: { biz: 'buz', foo: 'bar' } , url: {':id', 14}}
I need that for faxios
Should we consider adding support for mailto
URI and others alike? Or would that be out of scope of this module?
Currently, unlike http
and https
, mailto
appears to somehow be treated like a relative URL as a leading slash is prepended to the output.
Branch | Build failing π¨ |
---|---|
Dependency | babel-preset-moxy |
Current Version | 2.3.3 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
babel-preset-moxy is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 2 commits.
d94c357
chore(release): 2.3.4
722526c
fix: fix dev errors when using transform-react-inline-elements
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
When joining full urls it removes the second /
Example:
import urlJoin from 'proper-url-join';
const test = urlJoin('http://localhost','test','v1', { leadingSlash: false, });
It returns http:/localhost/test/v1
When using with Angular 10, I'm getting this error:
ERROR in ./node_modules/proper-url-join/es/index.js 80:46-57
"export 'default' (imported as 'queryString') was not found in 'query-string'
ERROR in ./node_modules/proper-url-join/es/index.js 82:17-28
"export 'default' (imported as 'queryString') was not found in 'query-string'
Might that syntheticDefaultImport in Line 1 be a problem in some cases? Should be replaceable by import * as queryString from 'query-string';
afaik.
Update: import * as queryString from 'query-string';
did not solve it for me, there seems to be a problem with the query-string
dependency itself. I tried to install the fixed version "query-string": "6.3.0",
, but still had no luck.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.