npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cisurls

v0.1.13

Published

Some basic UIUC CIS API URL utilities. Fix URLs from the documentation, take API url and make it courses.illinois.edu web page URL, etc.

Downloads

15

Readme

UIUC CIS API URL Tools

npm version License: MIT Build Status

Some very basic UIUC Course Information Suite(CIS) API URL utilities. Fix URLs from the documentation(from cisapi to cisapp/explorer) to make them plug-and-play, take API URL(cisapp/explorer) and make it courses.illinois.edu web page URL, and maybe more in the future.

A web interface for this module is available at mirth.cc/cisurls-web.

Info

The fixDocumentationURL() function reliably handles:

  • /schedule/ endpoints

It does not handle:

  • /catalog endpoints (use /schedule instead)
  • /gened endpoints (use /schedule/courses instead)
  • /term endpoints (use /schedule instead)
  • /subject endpoints (use /schedule instead)

Installation

Install via npm:

npm install cisurls

Usage

const { fixDocumentationURL, convertCourseURL } = require("cisurls");
// Fix a URL from the UIUC CIS API documentation
const fixedUrl = fixDocumentationURL(
  "http://courses.illinois.edu/cisapi/schedule/courses?year=2012&term=spring§ionTypeCode=LEC§ionTypeCode=Q&collegeCode=KV&creditHours=3&subject=CHEM&sessionId=1&gened=NAT&qp=atomic+structure"
);
console.log(fixedUrl);
// Convert a UIUC CIS API Course URL to a courses.illinois.edu URL
const courseUrl = convertCourseURL(
  "https://courses.illinois.edu/cisapp/explorer/schedule/2012/spring/AAS/120.xml"
);
console.log(courseUrl);

API

fixDocumentationURL(url, addCascade = false)

Fixes a URL from the UIUC CIS API documentation to work with the UIUC CIS Explorer.

Fixes the following:

  • Change “/cisapi” to “/cisapp/explorer”
  • Add .xml before the parameters. For example, change “/courses” to “/courses.xml”
  • Special case of missing & before § in schedule/courses endpoint.

Parameters:

  • url (string): The URL to be fixed.
  • addCascade (boolean, optional): If true, adds the "mode=cascade" parameter to the URL. Default is false.

convertCourseURL(url)

Converts a UIUC CIS API course URL to a courses.illinois.edu web page URL. (Beginning with http[s]://courses.illinois.edu/cisapp/explorer/schedule)

Does the following:

  • Change "/cisapp/explorer" to "/search"
  • Remove ".xml" from the end of the URL
  • Remove query parameters

Parameters:

  • url (string): The URL to be converted.

Throws

Here's an explanation of when these errors can be thrown:

  1. fixDocumentationURL(url, addCascade) and convertCourseURL(url) functions:

    • Both functions will throw an error if the provided url parameter is not a string:

      The "url" parameter must be a string.

    • Both functions will also throw an error if the provided url parameter is an empty string:

      The "url" parameter must not be an empty string.

    • Both functions will throw an error if the provided url parameter is not a valid URL:

      The "url" parameter must be a valid URL.

  2. fixDocumentationURL(url, addCascade) function:

    • If the provided url is not a UIUC CIS API URL:

      The "url" parameter must be a UIUC CIS API URL (like http(s)://courses.illinois.edu/cisapi/).

  3. convertCourseURL(url) function:

    • If the provided url is not a UIUC CIS Explorer URL:

      The "url" parameter must be a UIUC CIS API Explorer course URL (like https://courses.illinois.edu/cisapp/explorer/schedule/2012/spring/AAS/120.xml).

    • If the provided url does not match the pattern of a valid course URL on the UIUC CIS Explorer:

      The "url" parameter must be a UIUC CIS API Explorer course URL (like https://courses.illinois.edu/cisapp/explorer/schedule/2012/spring/AAS/120.xml).

In all these cases, the errors are thrown to ensure that the provided input meets the required format and structure. If any of these conditions are not met, the functions cannot guarantee the correct processing and conversion of the input URL.

Tests

Run tests with Jest:

npm test

License

This project is licensed under the MIT License. See the LICENSE file for more information.