{"id":17584540,"url":"https://github.com/kaustubhhiware/urlparamify","last_synced_at":"2025-04-28T16:22:02.788Z","repository":{"id":57387731,"uuid":"92662981","full_name":"kaustubhhiware/urlparamify","owner":"kaustubhhiware","description":"Parse all kinds of urls, simple or otherwise. Returns a modifiable JSON object that can be converted to a string.","archived":false,"fork":false,"pushed_at":"2017-06-23T08:32:35.000Z","size":20,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T00:53:20.679Z","etag":null,"topics":["javascript","json","node","nodejs","nodejs-modules","parse","parsing","parsing-library","url"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaustubhhiware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-28T13:31:04.000Z","updated_at":"2024-05-31T16:26:03.000Z","dependencies_parsed_at":"2022-09-06T09:41:47.332Z","dependency_job_id":null,"html_url":"https://github.com/kaustubhhiware/urlparamify","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaustubhhiware%2Furlparamify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaustubhhiware%2Furlparamify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaustubhhiware%2Furlparamify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaustubhhiware%2Furlparamify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaustubhhiware","download_url":"https://codeload.github.com/kaustubhhiware/urlparamify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342845,"owners_count":21574255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","json","node","nodejs","nodejs-modules","parse","parsing","parsing-library","url"],"created_at":"2024-10-22T02:06:49.330Z","updated_at":"2025-04-28T16:22:02.772Z","avatar_url":"https://github.com/kaustubhhiware.png","language":"JavaScript","readme":"# urlparamify\n\n\u003e Parse all kinds of urls, simple or otherwise. Returns a modifiable JSON object that can be converted to a string.\n\n[![NPM](https://nodei.co/npm/urlparamify.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/urlparamify/)\n\n[![Build Status](https://travis-ci.org/kaustubhhiware/urlparamify.svg?branch=master)](https://travis-ci.org/kaustubhhiware/urlparamify) [![Coverage Status](https://coveralls.io/repos/github/kaustubhhiware/urlparamify/badge.svg?branch=master)](https://coveralls.io/github/kaustubhhiware/urlparamify?branch=master)\n\n## The why\n\nPrimary goal: Keep urls modifiable, without worrying about anything else.\nAllow for modifying urls, and generating a neat url with accomodated changes.\n\nOften you might be parsing urls, modifying some parameter using strings,\nand the whole system looks messy. [`urlparamify`](https://www.npmjs.com/package/urlparamify)\nseeks to solve that problem. Just give it a string, which is converted\ninto JSON modifiable form. Mess up any way you want to with the parameters,\nplaying around with the params, and just call a `Url.toString()` to get your modified url.\n\nNow you don't need to worry about `google.com`, `http://google.com`, `/path?search=data`, \n`urlparamify` has got you covered.\n\nOne of the legit feedbacks I received on [reddit](https://www.reddit.com/r/node/comments/6e2bga/urlparamify_parse_all_kinds_of_url_simple_and/) \nwas how is this module any different from the core url module ?\n\nUnlike the core `url`, `urlparamify` accepts any kind of url like mentioned \nabove, whereas `url` works only when a url of the format `http://google.com` is \nprovided. I started off working on a task with `url` itself, but the multiple \nfallacies in url (url.parse('http://google.com') for instance, along with \nmultiple urls mentioned in this test suite) and other interactions suggested me \nto make a url suited to these requirements. An instance of this module's sturdiness \ncan be seen in Usage and examples below.\n\nFind a url that breaks this module ? Let me know.\n\n\n## Installation\n\n    $ npm install urlparamify\n\n## Structure\n\nEach url is broken down into the following components:\n\n* `href` : The original input string\n* `protocol` : http / https request protocol\n* `host` : what website / localhost ip,port combination\n* `baseurl` : The base url of the url to be queried.\n* `path` : Path section of the URL\n* `query` : The query part of the url, unaltered\n* `queryParams` : A json object to modify/add to your query\n\nApart from this, each url object has the following functions:\n\n* `getBaseurl()`: Get the latest baseurl parameter\n* `toString()` : Convert our url object into a neatly formatted string.\n\n## Usage and examples\n```js\n\u003e var Url = require('urlparamify');\n\u003e var h = Url('http://google.com/path1?q=data\u0026d=sad#hash');\n\n\u003e h\n{ href: 'http://google.com/path1/?q=data\u0026d=sad#hash',\nprotocol: 'http',\nhost: 'google.com',\nbaseurl: 'http://google.com',\npath: 'path1',\nquery: 'q=data\u0026d=sad',\nqueryParams: { q: 'data', d: 'sad' },\nhash: 'hash',\ngetBaseurl: [Function],\ntoString: [Function] }\n\n\u003e h.toString();\n'http://google.com/path1?q=data\u0026d=sad#hash'\n\n// let's put a smile on that face\n\u003e h.queryParams.d = 'happy';\n\u003e h.toString();\n'http://google.com/path1?q=data\u0026d=happy#hash'\n\n// let's try adding new query parameters\n\u003e h.queryParams.new = 'wow';\n\u003e h.toString();\n'http://google.com/path1?q=data\u0026d=happy\u0026new=wow#hash'\n\n// I don't like hashtags. Get rid of it\n\u003e h.hash = \"\";\n\u003e h.toString();\n'http://google.com/path1?q=data\u0026d=sad\u0026new=wow'\n\n// But what if I want to add things that were never there to begin with ?\n// With urlparamify, you can not only modify, but also add new parameters with ease\n\u003e var g = Url('google.com')\n\u003e g.toString()\n'google.com'\n\u003e g.path = 'somepath'\n\u003e g.toString()\n'google.com/somepath'\n\u003e g.queryParams.search = 'data'\n\u003e g.toString()\n'google.com/somepath?search=data'\n\n```\n\n## Tests\n\n    npm test\n    npm run cover\n    istanbul cover test/test.js // The results are stored in coverage/\n\n\nThe source files are in [`src`](src/), and the distribution files are in [`dist`](dist/). Transpiled the code for ease.\n\nA little reminder for myself: When ready to deploy, at a clean git history,\n\n    npm version patch -m \"Version %s - add sweet badges\"\n    major.minor.patch : 1.1.0\n\nIf you want to publish your own module, [this article on Medium](https://medium.com/@jdaudier/how-to-create-and-publish-your-first-node-js-module-444e7585b738) is a great place to start.\n\n\n## License\n\nMIT © [Kaustubh Hiware](https://kaustubhhiware.github.io)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaustubhhiware%2Furlparamify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaustubhhiware%2Furlparamify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaustubhhiware%2Furlparamify/lists"}