Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
--HG--
branch : release
  • Loading branch information
kazssym committed Apr 17, 2020
2 parents 1f9ac99 + 5e7df7a commit ff58847
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 25 deletions.
9 changes: 9 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# FUNDING.yml - GitHub sponsor button configuration
# Copyright (C) 2019 Kaz Nishimura
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
---
custom:
- https://salt.bountysource.com/checkout/amount?team=vx68k
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files.exclude": {
"**/*.rej": true,
"**/*.orig": true,
"**/*~": true
}
"files.exclude": {
"**/*.rej": true,
"**/*.orig": true,
"**/*~": true
}
}
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This file documents the current guidelines for contributing.

# Conventions

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”,
“SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be
interpreted as described in [BCP 14][] when, and only when, they appear in all
capitals, as shown here.

[BCP 14]: https://tools.ietf.org/html/bcp14

# Pull request guidelines

## File encoding

Unless mandated by the media type, a file SHOULD be encoded either in `UTF-8`
(preferred) or in `US-ASCII`, and if it would be in `UTF-8`, it MUST NOT
contain any BOM (U+FEFF).

## End-of-line convention

Unless mandated by the media type, each line of a file SHOULD end with a single
LF (U+000A).
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ This file documents the `redirect.js` script.

# Description

The `redirect.js` script redirects modern web browsers to another location
without any server configuration.
The `redirect.js` script redirects web browsers to another location *without
any server configuration*.
It is *not a script for Node.js* but for web browsers.

[![(License)](https://img.shields.io/badge/license-MIT-blue.svg)][MIT]
Expand Down
39 changes: 39 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# azure-pipelines.yml - configuration for Azure Pipelines
# Copyright (C) 2020 Kaz Nishimura
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
---
trigger:
- master
- release/*
- feature/*
stages:
- stage: Default
jobs:
- job: Build
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
- bash: |
npm test
displayName: Test
- task: PublishTestResults@2
condition: succeededOrFailed()
- stage: Release
dependsOn: Default
condition:
and(succeeded(),
startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))
jobs:
- job: Upload
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
- task: Npm@1
inputs:
command: publish
publishEndpoint: npmjs
22 changes: 20 additions & 2 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,31 @@ definitions:
steps:
- step: &test
name: Test
image: node:8
caches:
- node
script:
- npm config set unsafe-perm true
- npm install
- npm test
image: node:8
- step: &package
name: Packaging
image: node:8
caches:
- node
script:
- npm config set unsafe-perm true
- npm install
- npm pack
artifacts:
- "*.tgz"
pipelines:
branches:
default:
master:
- step: *test
deployment/test:
- step:
<<: *package
pull-requests:
"**":
- step: *test
File renamed without changes.
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{
"name": "@kazssym/redirect",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.4",
"description": "Module script to redirect web browsers to another location without any server configuration.",
"keywords": [
"browser",
"es2015",
"module"
],
"homepage": "https://vx68k.bitbucket.io/redirect.js/",
"license": "MIT",
"author": {
"name": "Kaz Nishimura",
"email": "kazssym@linuxfront.com"
},
"files": [
"prepack.sh",
"etc/*",
"**/*.js"
],
"browser": {},
"repository": {
"type": "hg",
"url": "https://bitbucket.org/vx68k/redirect.js"
"type": "git",
"url": "https://github.com/vx68k/redirect.js.git"
},
"scripts": {
"prepack": "sh ./prepack.sh"
"prepack": "sh ./etc/prepack.sh"
},
"devDependencies": {
"terser": "~4"
Expand Down
42 changes: 31 additions & 11 deletions redirect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// redirect.js - browser script to redirect the browser to a new location
// redirect.js - module script to redirect web browsers to another location
// Copyright (C) 2019 Kaz Nishimura
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -24,7 +24,7 @@
// NOTE: this file is a module script.

/**
* Browser script to redirect the browser to a new location.
* Module script to redirect web browsers to another location.
*
* This script can be loaded in a *redirecting* HTML file as follows:
*
Expand All @@ -50,6 +50,31 @@
*/
const PACKAGE_VERSION = "@PACKAGE_VERSION@";

/**
* Module name.
*
* @private
*/
const MODULE_NAME = "redirect.js";

/**
* Returns the canonical link of the document.
*
* @return {HTMLLinkElement} the canonical link
*/
export function getCanonicalLink()
{
let root = document.documentElement;
for (let link of root.getElementsByTagName("link")) {
for (let type of link.relList) {
if (type.toLowerCase() == "canonical") {
return link;
}
}
}
return null;
}

/**
* Redirects the browser to the location specified by the `data-new-location`
* attribute of the root element or the `canonical` link of the document,
Expand All @@ -66,13 +91,9 @@ export function run()
newLocation = root.dataset.newLocation;
}
if (newLocation == null) {
for (let link of root.getElementsByTagName("link")) {
for (let type of link.relList) {
if (type.toLowerCase() == "canonical") {
newLocation = link.href;
break;
}
}
let link = getCanonicalLink();
if (link != null) {
newLocation = link.href;
}
}

Expand All @@ -82,6 +103,5 @@ export function run()
}
}

console.info("Loaded: %s (%s %s)", "redirect.js",
PACKAGE_NAME, PACKAGE_VERSION);
console.info("Loaded: %s (%s %s)", MODULE_NAME, PACKAGE_NAME, PACKAGE_VERSION);
run();
20 changes: 20 additions & 0 deletions upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
# upload.sh - file uploader for Bitbucket Cloud
# Copyright (C) 2018 Kaz Nishimura
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.

REPOSITORY=vx68k/netbeans-bitbucket-plugin

test -n "$USERNAME" || exit 0

for file in "$@"; do
FILES="$FILES --form files=@\"$file\""
done
test -n "$FILES" || exit 1

exec curl --silent --show-error --user "$USERNAME${PASSWORD+:$PASSWORD}" \
--request POST $FILES \
https://api.bitbucket.org/2.0/repositories/$REPOSITORY/downloads

0 comments on commit ff58847

Please sign in to comment.